|
| 1 | +name: Release - Bump Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_type: |
| 7 | + description: "Version Type?" |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - major |
| 12 | + - minor |
| 13 | + - patch |
| 14 | + default: "minor" |
| 15 | + |
| 16 | +jobs: |
| 17 | + Create-PR-To-Bump-Fetch-Metadata-Version: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + # Ensure we start from main in case the workflow is run from a branch |
| 24 | + ref: "main" |
| 25 | + token: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }} |
| 26 | + |
| 27 | + - uses: actions/setup-node@v3 # bin/bump-version needs npm |
| 28 | + with: |
| 29 | + node-version-file: .nvmrc |
| 30 | + |
| 31 | + - name: Bump the version |
| 32 | + # Currently we don't run via `schedule` trigger since this repo isn't active enough. |
| 33 | + # However, if that ever changes, it will run with no inputs, so version_type will default to 'minor' |
| 34 | + run: | |
| 35 | + NEW_VERSION=$(bin/bump-version ${{ github.event.inputs.version_type || 'minor' }}) |
| 36 | + echo "New version is: $NEW_VERSION" |
| 37 | + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - name: Configure the git user |
| 40 | + run: | |
| 41 | + git config user.name "github-actions[bot]" |
| 42 | + # Specifying the full email allows the avatar to show up: https://github.com/orgs/community/discussions/26560 |
| 43 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 44 | +
|
| 45 | + - name: Create a branch and commit the changes |
| 46 | + run: | |
| 47 | + # Using an idempotent branch name ensures no duplicate PR's are created |
| 48 | + # if the action is re-run before the previous PR is merged. |
| 49 | + # The branch name is purposefully different from the release tag to |
| 50 | + # avoid ambiguity when selecting git refs. |
| 51 | + git checkout -b "bump-to-${{ env.NEW_VERSION }}" |
| 52 | + git add package.json package-lock.json |
| 53 | + echo "Creating commit / PR linking to the releases notes URL." |
| 54 | + echo "This URL will 404 until the release is actually tagged, which you should do as soon as the PR is merged." |
| 55 | + git commit -m "${{ env.NEW_VERSION }}" -m "Release notes: https://github.com/${{ github.repository }}/releases/tag/${{ env.NEW_VERSION }}" |
| 56 | +
|
| 57 | + - name: Push the branch |
| 58 | + run: | |
| 59 | + echo "Pushing branch to remote. If this fails, check if a branch/PR already exists for this version." |
| 60 | + git config push.autoSetupRemote true |
| 61 | + git push |
| 62 | +
|
| 63 | + - name: Create a PR from the branch with the commit |
| 64 | + run: | |
| 65 | + PR_URL=$(gh pr create --fill) # `fill` re-uses the title / body from the commit |
| 66 | + echo "PR created at URL: $PR_URL" |
| 67 | + echo "PR_URL=$PR_URL" >> $GITHUB_ENV |
| 68 | + env: |
| 69 | + GH_TOKEN: ${{ secrets.DEPENDABOT_AUTOMATION_PAT }} |
| 70 | + |
| 71 | + - name: Set summary |
| 72 | + run: | |
| 73 | + echo ":rocket: PR created at URL: ${{ env.PR_URL }}" >> $GITHUB_STEP_SUMMARY |
| 74 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 75 | + echo "After the PR is approved/merged, create a new release tagged as \`${{ env.NEW_VERSION }}\`, _making sure to point it at the merge commit_:" >> $GITHUB_STEP_SUMMARY |
| 76 | + echo "* You can do this via the web UI - use the \`Generate release notes\` button and then edit as needed: https://github.com/${{ github.repository }}/releases/new?tag=${{ env.NEW_VERSION }}&title=${{ env.NEW_VERSION }}" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "* Or via the GitHub CLI:" >> $GITHUB_STEP_SUMMARY |
| 78 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
| 79 | + echo " gh release create ${{ env.NEW_VERSION }} --title ${{ env.NEW_VERSION }} --generate-notes --draft" >> $GITHUB_STEP_SUMMARY |
| 80 | + echo " > https://github.com/${{ github.repository }}/releases/tag/untagged-XXXXXX" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo " # Use the generated URL to review/edit the release notes." >> $GITHUB_STEP_SUMMARY |
| 82 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "Once the release is tagged, move the floating \`v1\` tag to point at this release." >> $GITHUB_STEP_SUMMARY |
0 commit comments