Skip to content

Commit 1c3df29

Browse files
authored
infra(release): draft release (#2990)
1 parent 392d26e commit 1c3df29

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/draft-release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Draft Release
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
paths:
8+
- 'CHANGELOG.md'
9+
10+
permissions:
11+
contents: write # to create releases
12+
13+
jobs:
14+
draft_release:
15+
name: Draft Release
16+
if: >
17+
startsWith(github.event.pull_request.title, 'chore(release):')
18+
&& github.event.pull_request.merged
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
25+
with:
26+
fetch-depth: 0 # we need the tags and the commit history for the gh release create command
27+
ref: ${{ github.event.pull_request.base.ref }}
28+
29+
- name: Gather release information
30+
run: |
31+
RELEASE_VERSION=$(jq -r '.version' package.json)
32+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
33+
PREVIOUS_VERSION=$(git describe --tags --abbrev=0)
34+
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV
35+
if [[ "$RELEASE_VERSION" == *"-"* ]]; then
36+
RELEASE_ARGS="--prerelease"
37+
else
38+
RELEASE_ARGS="--latest"
39+
fi
40+
echo "RELEASE_ARGS=$RELEASE_ARGS" >> $GITHUB_ENV
41+
42+
- name: Create draft release
43+
run: |
44+
gh release create \
45+
v$RELEASE_VERSION \
46+
--draft \
47+
$RELEASE_ARGS \
48+
--generate-notes \
49+
--notes-start-tag $PREVIOUS_VERSION \
50+
--title v$RELEASE_VERSION
51+
env:
52+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)