-
-
Notifications
You must be signed in to change notification settings - Fork 34
98 lines (89 loc) · 2.97 KB
/
Copy pathfinalise-release.yml
File metadata and controls
98 lines (89 loc) · 2.97 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
name: Finalise Release Tags
on:
workflow_dispatch:
inputs:
version:
description: Release version, for example 0.18.18
required: true
type: string
release_branch:
description: Release PR branch. Defaults to release/<version>.
required: false
type: string
expected_head_sha:
description: Full head commit SHA reviewed in the release PR
required: true
type: string
concurrency:
group: finalise-release
cancel-in-progress: false
jobs:
finalise:
runs-on: ubuntu-latest
environment: release
permissions:
actions: write
contents: write
steps:
- name: Resolve release branch
id: branch
env:
VERSION: ${{ inputs.version }}
RELEASE_BRANCH_INPUT: ${{ inputs.release_branch }}
run: |
set -euo pipefail
BRANCH="${RELEASE_BRANCH_INPUT}"
if [[ -z "${BRANCH}" ]]; then
BRANCH="release/${VERSION}"
fi
git check-ref-format --branch "${BRANCH}"
echo "name=${BRANCH}" >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
with:
ref: ${{ steps.branch.outputs.name }}
fetch-depth: 0
- name: Validate release head
env:
VERSION: ${{ inputs.version }}
EXPECTED_HEAD_SHA: ${{ inputs.expected_head_sha }}
run: |
set -euo pipefail
ACTUAL_HEAD_SHA="$(git rev-parse HEAD)"
if [[ "${ACTUAL_HEAD_SHA}" != "${EXPECTED_HEAD_SHA}" ]]; then
echo "Release branch head is ${ACTUAL_HEAD_SHA}, expected ${EXPECTED_HEAD_SHA}." >&2
exit 1
fi
node release-process.mjs validate "${VERSION}"
git fetch --tags --force
if git rev-parse --verify --quiet "refs/tags/${VERSION}" >/dev/null; then
echo "Release tag already exists: ${VERSION}" >&2
exit 1
fi
- name: Create and push release tag
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
git tag "${VERSION}"
git push origin "${VERSION}"
- name: Dispatch release workflow
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
gh workflow run release.yml \
--ref "${VERSION}" \
--field tag="${VERSION}" \
--field draft=true \
--field prerelease=false
- name: Summarise next steps
env:
VERSION: ${{ inputs.version }}
run: |
{
echo "Created tag \`${VERSION}\` and explicitly dispatched the release workflow."
echo ""
echo "Approve the release environment, inspect and publish the draft GitHub Release, then validate it with BRAT."
echo "Keep the release pull request in draft until BRAT succeeds, then merge it with a merge commit."
} >> "${GITHUB_STEP_SUMMARY}"