Skip to content

Create release PR

Create release PR #66

name: Create release PR
permissions:
contents: read
on:
workflow_dispatch:
inputs:
version:
description: 'The version number to release (has priority over release_type)'
type: string
release_type:
description: Type of release
type: choice
default: patch
options:
- patch
- minor
- major
jobs:
create-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
version: ${{ steps.bump.outputs.version }}
steps:
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
id: checkout
with:
persist-credentials: true
- name: Validate release branch
run: |
if [ '${{ github.ref_name }}' != 'v7.x' ]; then
echo 'This workflow must run from v7.x (current ref: ${{ github.ref_name }}).'
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
id: setup-node
with:
node-version: 'lts/*'
- name: Git Config
id: git-config
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Change version number and push
id: bump
run: |
npm version ${{ inputs.version || inputs.release_type }} --git-tag-version=false
VERSION=`jq -r ".version" package.json`
RELEASE_BRANCH="release/v$VERSION"
git add -u
git commit -m "Bumped v$VERSION"
git push origin "HEAD:$RELEASE_BRANCH"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create PR
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
id: create-pr
with:
script: |
const releaseBranch = '${{ github.ref_name }}'
const versionTag = 'v${{ steps.bump.outputs.version }}'
const commitHash = '${{ github.sha }}'
await require('./scripts/release').generatePr({ github, context, releaseBranch, versionTag, commitHash })