-
Notifications
You must be signed in to change notification settings - Fork 33
101 lines (86 loc) · 2.99 KB
/
Copy pathcreate-release-pr.yml
File metadata and controls
101 lines (86 loc) · 2.99 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
- 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
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version_bump.outputs.version }}"
gh pr create \
--base master \
--head $RELEASE_BRANCH \
--title "chore(release): v$VERSION" \
--body-file - <<EOF
## Release v$VERSION
Version bump and changelog updates.
Triggered by: ${{ github.actor }}
<!-- === GH HISTORY FORMAT FENCE === --> <!--
### [\`%h\`]({{.url}}/commits/%H) %s%n%n%b%n
--> <!-- === GH HISTORY FORMAT FENCE === -->
<!-- === GH HISTORY FENCE === -->
Do NOT write here! This section will be filled in by GitHub Action
automatically. If you don't want this, either remove the markers or write
outside the fences.
<!-- === GH HISTORY FENCE === -->
EOF