chore(deps): lock file maintenance #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release packages | |
on: | |
pull_request: | |
types: [closed, labeled] | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'released') | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8.4.0 | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
env: | |
cache-name: casl-deps | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Release | |
env: | |
GH_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }} | |
run: | | |
changed_packages=$(gh pr view --json files --jq '.files.[].path' "${{ github.event.pull_request.number }}" | cut -d / -f 1,2 | uniq) | |
pnpm_options='' | |
for path in $changed_packages; do | |
pnpm_options="${pnpm_options} --filter ./${path}" | |
done | |
pnpm run -r $pnpm_options release | |
released_packages=() | |
for path in $changed_packages; do | |
package_name=$(grep '"name":' $path | cut -d : -f 2 | cut -d '"' -f 2) | |
package_version=$(grep '"version":' $path | cut -d : -f 2 | cut -d '"' -f 2) | |
released_packages[${#released_packages[@]}]="${package_name}@${package_version}" | |
done | |
gh pr comment "${{ github.event.pull_request.number }}" --body "🚀 Released in ${released_packages[@]}" |