Skip to content

chore(release): prepare release v1.4.0 #4

chore(release): prepare release v1.4.0

chore(release): prepare release v1.4.0 #4

name: Prepare Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to bump to (e.g. patch, minor, major, or specific version)"
required: true
default: "patch"
pull_request:
types: [closed]
branches: [main]
jobs:
prepare-release:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
HUSKY: 0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies
run: npm ci
- name: Update version
run: |
npm version ${{ github.event.inputs.version }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Generate changelog
run: npx conventional-changelog-cli@4.1.0 -p angular -i CHANGELOG.md -s
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore(release): v${{ env.NEW_VERSION }}"
title: "chore(release): prepare release v${{ env.NEW_VERSION }}"
body: |
Prepare release v${{ env.NEW_VERSION }}
- Update version in package.json
- Update CHANGELOG.md
base: main
branch: release/v${{ env.NEW_VERSION }}
create-tag:
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Get version
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Extract release notes
run: |
node <<'EOF'
const fs = require("fs");
const version = process.env.VERSION;
const changelog = fs.readFileSync("CHANGELOG.md", "utf8");
const pattern = new RegExp(
`#+ \\[${version.replace(/\./g, "\\.")}\\][\\s\\S]*?(?=\\n#+ \\[|$)`,
);
const match = changelog.match(pattern);
fs.writeFileSync(
"release-notes.md",
match ? match[0].trim() : `Release v${version}`,
);
EOF
env:
VERSION: ${{ steps.version.outputs.version }}
- name: Create tag and GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body_path: release-notes.md
generate_release_notes: false