-
Notifications
You must be signed in to change notification settings - Fork 59
54 lines (46 loc) · 1.73 KB
/
Copy pathdraft-release.yml
File metadata and controls
54 lines (46 loc) · 1.73 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
name: Draft Release
# When a "Release X.Y.Z" PR (opened by the Create Release PR workflow) is
# merged into master, this prepares a DRAFT GitHub Release with the right tag
# and auto-generated notes. It is intentionally left as a draft — a human
# clicks "Publish" to actually ship, which triggers release.yml + executable.yml.
on:
pull_request:
types: [closed]
permissions:
contents: write
jobs:
draft:
# Only for merged PRs whose title starts with "Release " (our bump PRs).
if: >-
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.title, 'Release ')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Create draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
set -euo pipefail
VERSION=$(node -p "require('./lerna.json').version")
TAG="v$VERSION"
# Mark betas (versions containing a hyphen) as pre-releases.
PRERELEASE_FLAG=""
if [[ "$VERSION" == *-* ]]; then
PRERELEASE_FLAG="--prerelease"
fi
# Don't recreate if a draft/release for this tag already exists.
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists — skipping."
exit 0
fi
gh release create "$TAG" \
--draft \
--generate-notes \
--title "$TAG" \
--target "$TARGET_SHA" \
$PRERELEASE_FLAG
echo "Created draft release $TAG. Review it and click Publish to ship."