This repository was archived by the owner on Jan 30, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (65 loc) · 2.28 KB
/
release-package.yml
File metadata and controls
74 lines (65 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Release Package
on:
push:
branches: [main, stable, "*.x"]
paths:
- "src/**"
- "!**.md"
- "package.json"
workflow_dispatch:
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v5
with:
node-version: 22
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile
- run: pnpm build
# - run: pnpm test
- name: Release
id: release
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm dlx semantic-release
- name: Create sync PR to main
if: github.ref == 'refs/heads/stable'
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
pr_number=$(gh pr list --base main --head stable --state open --json number --jq '.[0].number')
if [ -z "$pr_number" ]; then
git fetch origin main
if git diff --quiet origin/main...HEAD; then
echo "Main is already up to date with stable; skipping PR."
exit 0
fi
pr_url=$(gh pr create --base main --head stable --title "chore: sync stable release to main" --body "Automated PR to merge the latest stable changes back into main.")
pr_number=$(echo "$pr_url" | grep -oE '[0-9]+$')
echo "Created PR #$pr_number to sync stable into main."
else
echo "PR #$pr_number already open to sync stable into main."
fi
gh pr merge "$pr_number" --merge --auto || echo "Auto-merge setup skipped (conditions not met)."