Make Release Bump PR #9
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: Make Release Bump PR | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
required: true | |
type: choice | |
description: Select the new Semantic Version | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
bump_release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Input Log | |
run: | | |
echo "📝 Inputs" | |
echo "semver: ${{ inputs.semver }}" | |
shell: bash | |
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version-file: ".node-version" | |
- run: yarn install --frozen-lockfile | |
- name: Bump Package Version | |
id: bump | |
run: | | |
npm version ${{ inputs.semver }} --no-git-tag-version | |
shell: bash | |
- id: semver | |
name: New Version | |
run: | | |
NEXT_VERSION=$(node -p "require('./package.json').version") | |
echo "new_version=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Push New Version to new branch | |
id: new_branch_push | |
shell: bash | |
env: | |
NEW_BRANCH_NAME: releases/${{ steps.semver.outputs.new_version }} | |
run: | | |
echo "new_branch_name=$NEW_BRANCH_NAME" >> $GITHUB_OUTPUT | |
git checkout -b $NEW_BRANCH_NAME | |
git add . | |
git config --global user.email "[email protected]" | |
git config --global user.name "pagopa-github-bot" | |
git commit -m "Bump to version ${{ steps.semver.outputs.new_version }}" || exit 0 | |
git push -u origin $NEW_BRANCH_NAME | |
- name: Create release pull request | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | |
gh pr create -B master -H ${{ steps.new_branch_push.outputs.new_branch_name }} --title 'Release version ${{ steps.semver.outputs.new_version }} pull request' --body 'This PR has been created by a Github Action' -l 'release' |