Improve documentation #10
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
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
name: Update versions and create release PR | |
jobs: | |
is_merged: | |
name: Check that PR was merged and not closed | |
if: > | |
github.event.pull_request.merged == true | |
&& ( contains(github.event.pull_request.labels.*.name, 'major') | |
|| contains(github.event.pull_request.labels.*.name, 'minor') | |
|| contains(github.event.pull_request.labels.*.name, 'patch') | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo "This is a canonical hack to run GitHub Actions on merged PRs" | |
echo "See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges" | |
release: | |
name: Bump version and create PR | |
needs: is_merged | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Bump version | |
id: bump_version | |
env: | |
is_major: ${{ contains(github.event.pull_request.labels.*.name, 'major') }} | |
is_minor: ${{ contains(github.event.pull_request.labels.*.name, 'minor') }} | |
is_patch: ${{ contains(github.event.pull_request.labels.*.name, 'patch') }} | |
run: | | |
sudo apt-get install jq | |
echo "old_version=$(jq '.version' package.json | tr -d '"')" >> "$GITHUB_OUTPUT" | |
if [[ "$is_major" == "true" ]]; then | |
npm version major --no-git-tag-version | |
elif [[ "$is_minor" == "true" ]]; then | |
npm version minor --no-git-tag-version | |
elif [[ "$is_patch" == "true" ]]; then | |
npm version patch --no-git-tag-version | |
fi | |
echo "new_version=$(jq '.version' package.json | tr -d '"')" >> "$GITHUB_OUTPUT" | |
- name: Create release PR | |
id: release_pr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: release/${{ steps.bump_version.outputs.new_version }} | |
delete-branch: true | |
base: main | |
title: Release version ${{ steps.bump_version.outputs.new_version }} | |
body: | | |
Update version to ${{ steps.bump_version.outputs.new_version }}. | |
Merge this PR to build and publish a new release. | |
labels: release | |
- name: Comment on PR with link to release PR | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
A [PR][pr] to release these changes has been created, bumping the version from ${{ steps.bump_version.outputs.old_version }} to ${{ steps.bump_version.outputs.new_version }}. | |
[pr]: ${{ steps.release_pr.outputs.pull-request-url }} |