-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (140 loc) · 4.66 KB
/
Copy pathrelease.yml
File metadata and controls
159 lines (140 loc) · 4.66 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 0.1.0, without v prefix)'
required: true
ref:
description: 'Git ref to release. Defaults to main.'
required: false
default: 'main'
env:
GORELEASER_VERSION: v2.14.3
permissions:
contents: write
concurrency:
group: prepare-release-${{ inputs.version }}
cancel-in-progress: false
jobs:
validate:
uses: ./.github/workflows/reusable-validate-release.yml
with:
version: ${{ inputs.version }}
ref: ${{ inputs.ref }}
go-checks:
needs: validate
uses: ./.github/workflows/reusable-go.yml
with:
ref: ${{ needs.validate.outputs.sha }}
npm-checks:
needs: validate
uses: ./.github/workflows/reusable-npm.yml
with:
ref: ${{ needs.validate.outputs.sha }}
version: ${{ needs.validate.outputs.version }}
e2e:
needs: validate
uses: ./.github/workflows/reusable-e2e.yml
with:
timeout-minutes: 20
publish-dry-run:
name: GoReleaser Dry Run
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ needs.validate.outputs.sha }}
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Run GoReleaser snapshot
run: |
curl -sfL https://goreleaser.com/static/run | VERSION="$GORELEASER_VERSION" bash -s -- release --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
- name: Dry-run npm publish
working-directory: npm
run: |
CURRENT="$(jq -r .version package.json)"
DESIRED="${{ needs.validate.outputs.version }}"
if [ "$CURRENT" != "$DESIRED" ]; then
npm version "$DESIRED" --no-git-tag-version
else
echo "Version already correct: $CURRENT"
fi
npm publish --dry-run
approval:
name: Manual Approval
needs:
- validate
- go-checks
- npm-checks
- e2e
- publish-dry-run
if: >-
always() && !cancelled()
&& needs.validate.result == 'success'
&& needs.go-checks.result == 'success'
&& needs.publish-dry-run.result == 'success'
runs-on: ubuntu-latest
environment:
name: release-approval
steps:
- name: Report check results
run: |
echo "## Pre-Release Check Results" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Check | Status |" >> "$GITHUB_STEP_SUMMARY"
echo "|-------|--------|" >> "$GITHUB_STEP_SUMMARY"
echo "| Go | ✅ |" >> "$GITHUB_STEP_SUMMARY"
echo "| npm | ${{ needs.npm-checks.result == 'success' && '✅' || '⚠️ ' }}${{ needs.npm-checks.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| E2E | ${{ needs.e2e.result == 'success' && '✅' || '⚠️ ' }}${{ needs.e2e.result }} |" >> "$GITHUB_STEP_SUMMARY"
echo "| GoReleaser dry run | ✅ |" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "Release candidate: **${{ needs.validate.outputs.tag }}** at \`${{ needs.validate.outputs.sha }}\`" >> "$GITHUB_STEP_SUMMARY"
create-tag:
name: Create Release Tag
needs:
- validate
- approval
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ needs.validate.outputs.sha }}
- name: Create and push tag
run: |
TAG="${{ needs.validate.outputs.tag }}"
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
echo "tag $TAG already exists on origin" >&2
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "refs/tags/$TAG"
- name: Summarize
run: |
echo "## Release Tag Created" >> "$GITHUB_STEP_SUMMARY"
echo "- Tag: ${{ needs.validate.outputs.tag }}" >> "$GITHUB_STEP_SUMMARY"
echo "- Commit: \`${{ needs.validate.outputs.sha }}\`" >> "$GITHUB_STEP_SUMMARY"
publish:
name: Publish Release
needs:
- validate
- create-tag
permissions:
contents: write
uses: ./.github/workflows/reusable-release-publish.yml
with:
ref: refs/tags/${{ needs.validate.outputs.tag }}
tag: ${{ needs.validate.outputs.tag }}
secrets: inherit