Update versions and changelogs #2
Workflow file for this run
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: Update versions and changelogs | |
on: create | |
jobs: | |
default: | |
name: Update versions and changelogs | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write # for updating PR | |
contents: write # for opening PR | |
env: | |
IS_RC_BRANCH: ${{ startsWith(github.ref_name, 'rc/v') }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
# this is a patch for incompatibility between lerna@7 and npm@9 https://github.com/lerna/lerna/issues/3418#issuecomment-1337756237 | |
- name: Remove lock file | |
if: env.IS_RC_BRANCH == 'true' | |
run: rm package-lock.json | |
- name: Get version number | |
if: env.IS_RC_BRANCH == 'true' | |
id: version-number | |
run: | | |
branch_name=${{ github.ref_name }} | |
version_number=${branch_name#rc/v} | |
echo "version_number=${version_number}" >> $GITHUB_OUTPUT | |
- name: Update versions and changelogs | |
if: env.IS_RC_BRANCH == 'true' | |
id: changelog | |
run: | | |
npm run bump-version ${{ steps.version-number.outputs.version_number }} | |
git add CHANGELOG.md | |
changelog=$(git diff HEAD CHANGELOG.md | tail -n +7 | cut -c 2-) | |
echo -e "changelog<<EOF"$'\n'"$changelog"$'\n'EOF >> $GITHUB_OUTPUT | |
- name: Set GPG | |
if: env.IS_RC_BRANCH == 'true' | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
- name: Open PR to rc branch | |
if: env.IS_RC_BRANCH == 'true' | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
title: Update versions and changelogs for ${{ steps.version-number.outputs.version_number }} | |
commit-message: 'chore: update versions and changelogs' | |
body: ${{ steps.changelog.outputs.changelog }} | |
committer: Chen Yu <[email protected]> | |
branch: chore-update-version-for-${{ github.ref_name }} | |
add-paths: ':!package-lock.json' |