Skip to content

Create Release PR

Create Release PR #18

name: Create Release PR
on:
workflow_dispatch:
inputs:
release-type:
description: 'Release type. `--conventional-prerelease` for prerelease or `--conventional-graduate` for stable.'
required: true
type: choice
options:
- '--conventional-prerelease --preid beta'
- '--conventional-graduate'
concurrency:
group: "release-pr"
cancel-in-progress: false
jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
RELEASE_BRANCH: zcli-release
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
filter: tree:0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.node-version'
cache: "yarn"
- name: Configure git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Check if release branch exists
run: |
if git ls-remote --exit-code --heads origin "$RELEASE_BRANCH" >/dev/null 2>&1; then
echo "Error: Release branch '$RELEASE_BRANCH' already exists on remote."
echo 'Please close/merge the existing release PR first, then delete the branch.'
exit 1
fi
- name: Create release branch
run: |
git checkout -b "$RELEASE_BRANCH"
- name: Install dependencies
run: |
yarn install --frozen-lockfile
- name: Version bump and update changelog
id: version_bump
run: |
yarn lerna version \
--conventional-commits \
${{ inputs.release-type }} \
--no-git-tag-version \
--yes
VERSION=$(node -p "require('./lerna.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Commit and push changes
run: |
git commit -am "chore(release): version bump"
git push origin $RELEASE_BRANCH