Skip to content

Commit 14d5703

Browse files
azuclaude
andcommitted
chore: add release workflows for GitHub Actions
- create-release-pr.yml: manually triggered workflow for version bump and release PR creation - release.yml: automated npm publish with provenance on release PR merge 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 84ef8c4 commit 14d5703

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Create Release PR
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
semver:
6+
description: "Select version bump type"
7+
required: true
8+
default: "patch"
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
jobs:
18+
create-release-pr:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: false
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
28+
- name: Setup Node.js
29+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
30+
with:
31+
cache: "pnpm"
32+
node-version: lts/*
33+
- name: Git config
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "github-actions[bot]@users.noreply.github.com"
37+
- name: Bump version
38+
run: npm version ${{ inputs.semver }} --no-git-tag-version
39+
- name: Get new version
40+
id: version
41+
run: echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT"
42+
- name: Generate release notes
43+
id: release-notes
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
TAG_NAME: v${{ steps.version.outputs.version }}
47+
run: |
48+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
49+
echo "notes<<$EOF" >> "$GITHUB_OUTPUT"
50+
gh api repos/${{ github.repository }}/releases/generate-notes \
51+
-f tag_name="$TAG_NAME" \
52+
--jq '.body' >> "$GITHUB_OUTPUT"
53+
echo "$EOF" >> "$GITHUB_OUTPUT"
54+
- name: Create Pull Request
55+
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11
56+
with:
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
commit-message: "chore: bump version to ${{ steps.version.outputs.version }}"
59+
title: "v${{ steps.version.outputs.version }}"
60+
body: |
61+
## Release v${{ steps.version.outputs.version }}
62+
63+
${{ steps.release-notes.outputs.notes }}
64+
branch: "release/${{ steps.version.outputs.version }}"
65+
labels: "Type: Release"
66+
draft: true

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
on:
3+
pull_request:
4+
types: [closed]
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Type: Release')
9+
permissions:
10+
contents: write
11+
id-token: write
12+
pull-requests: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
18+
- name: Setup Node.js
19+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
20+
with:
21+
cache: "pnpm"
22+
node-version: lts/*
23+
registry-url: "https://registry.npmjs.org"
24+
- name: Install dependencies
25+
run: pnpm install
26+
- name: Build
27+
run: pnpm run build
28+
- name: Publish to npm
29+
run: npm publish --provenance --access public
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
- name: Get version
33+
id: version
34+
run: echo "version=$(node -p 'require(\"./package.json\").version')" >> "$GITHUB_OUTPUT"
35+
- name: Create GitHub Release
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
TAG_NAME: v${{ steps.version.outputs.version }}
39+
run: |
40+
gh release create "$TAG_NAME" --generate-notes
41+
- name: Comment on PR (success)
42+
if: success()
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
PR_NUMBER: ${{ github.event.pull_request.number }}
46+
VERSION: ${{ steps.version.outputs.version }}
47+
run: |
48+
gh pr comment "$PR_NUMBER" --body "Released as v${VERSION}"
49+
- name: Comment on PR (failure)
50+
if: failure()
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
PR_NUMBER: ${{ github.event.pull_request.number }}
54+
run: |
55+
gh pr comment "$PR_NUMBER" --body "Release failed. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."

0 commit comments

Comments
 (0)