-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (56 loc) · 2.64 KB
/
Copy pathdraft-release.yml
File metadata and controls
62 lines (56 loc) · 2.64 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
name: Draft release
# Keeps a rolling draft release: every merge to main updates its changelog
# with the PRs merged since the last published release. Publishing the draft
# creates the tag that starts the release. See specs/release-process-spec.md.
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: read
jobs:
draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@4d75298e00d9e34c483e5ff8c68d0ea1c1940c1e # v7.5.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
# The Releases page must tell the truth before Publish is clicked: when
# the manifest version is already released, the draft carries a warning
# banner; once the manifests are bumped, the banner clears and the
# draft's tag/title default to the guard-passing v<version>.
- name: Sync the draft with the manifest version
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
VERSION="$(jq -r .version cli/deno.json)"
DRAFT_ID="$(gh api "repos/${{ github.repository }}/releases?per_page=10" --jq '[.[] | select(.draft)][0].id // empty')"
if [ -z "$DRAFT_ID" ]; then
echo "no draft release found"
exit 0
fi
gh api "repos/${{ github.repository }}/releases/$DRAFT_ID" --jq .body > /tmp/body.md
sed '/<!-- version-banner -->/,/<!-- \/version-banner -->/d' /tmp/body.md > /tmp/clean.md
if git ls-remote --exit-code origin "refs/tags/v$VERSION" >/dev/null 2>&1; then
IFS=. read -r MAJ MIN PAT <<< "$VERSION"
NEXT="$MAJ.$MIN.$(( ${PAT%%[!0-9]*} + 1 ))"
{
echo "<!-- version-banner -->"
echo "> [!WARNING]"
echo "> The manifests still declare \`$VERSION\`, which is already released."
echo "> Run \`deno task bump $NEXT\` (or the next minor/major) and merge the"
echo "> bump before publishing this draft (release spec §2)."
echo "<!-- /version-banner -->"
echo
cat /tmp/clean.md
} > /tmp/new.md
gh api -X PATCH "repos/${{ github.repository }}/releases/$DRAFT_ID" \
-F body=@/tmp/new.md >/dev/null
echo "draft flagged: manifests still at already-released $VERSION"
else
gh api -X PATCH "repos/${{ github.repository }}/releases/$DRAFT_ID" \
-f tag_name="v$VERSION" -f name="v$VERSION" -F body=@/tmp/clean.md >/dev/null
echo "draft synced to v$VERSION"
fi