Repository navigation
147 lines (128 loc) · 4.76 KB
/
Copy pathrelease.yaml
File metadata and controls
147 lines (128 loc) · 4.76 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
name: Build Release Draft
on:
workflow_call:
inputs:
tag:
type: string
required: true
sha:
description: Commit already verified before tagging
type: string
required: true
workflow_dispatch:
inputs:
tag:
description: Existing draft tag to rebuild (e.g. v0.24.0)
required: true
type: string
concurrency:
group: release-draft-${{ inputs.tag }}
cancel-in-progress: false
permissions:
contents: write
jobs:
resolve:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.resolve.outputs.sha }}
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ inputs.tag }}
fetch-depth: 0
- name: Verify the tag, version and approved commit
id: resolve
env:
TAG: ${{ inputs.tag }}
APPROVED_SHA: ${{ inputs.sha }}
run: |
CURRENT_SHA=$(git rev-parse HEAD)
python3 scripts/release/release.py check --tag "$TAG" --sha "${APPROVED_SHA:-$CURRENT_SHA}"
echo "sha=$CURRENT_SHA" >> "$GITHUB_OUTPUT"
test:
needs: resolve
if: github.event_name == 'workflow_dispatch' && inputs.sha == ''
uses: ./.github/workflows/test.yaml
with:
ref: ${{ needs.resolve.outputs.sha }}
release:
needs: [resolve, test]
if: always() && needs.resolve.result == 'success' && (needs.test.result == 'success' || needs.test.result == 'skipped')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.resolve.outputs.sha }}
fetch-depth: 0
- name: Require an unpublished draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
run: test "$(gh release view "$TAG" --json isDraft --jq .isDraft)" = true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 12.6.0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
cache-dependency-path: ui/pnpm-lock.yaml
- name: Build UI assets
run: cd ui && pnpm install --frozen-lockfile && pnpm run build
- name: Create UI archive and reviewed release notes
env:
TAG: ${{ inputs.tag }}
run: |
tar czf skillshare-ui-dist.tar.gz -C ui/dist .
# GoReleaser refuses a dirty tree. Exclude the archive locally, since a rebuild checks out
# an existing tag whose .gitignore cannot change.
echo /skillshare-ui-dist.tar.gz >> .git/info/exclude
python3 scripts/release/release.py notes --tag "$TAG" > "$RUNNER_TEMP/release-notes.md"
- name: Build and upload draft assets
uses: goreleaser/goreleaser-action@v6
with:
version: v2.18.2
args: release --clean --release-notes=${{ runner.temp }}/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify and upload the Homebrew formula and complete checksums
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
run: |
python3 scripts/release/release.py prepare-assets --assets dist
python3 scripts/release/release.py verify-assets --tag "$TAG" --assets dist
gh release upload "$TAG" dist/skillshare.rb dist/checksums.txt --clobber
- name: Add contributors to release notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
run: |
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || true)
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, skipping contributors"
exit 0
fi
# Get unique GitHub logins between tags (exclude bots and maintainer)
LOGINS=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...${TAG}" \
--jq '[.commits[].author.login // empty] | unique | .[]' 2>/dev/null \
| grep -v '\[bot\]$' \
| grep -v '^runkids$' || true)
if [ -z "$LOGINS" ]; then
echo "No external contributors found, skipping"
exit 0
fi
# Format as @mentions and render release notes from template
CONTRIBUTORS=$(echo "$LOGINS" | sed 's/^/@/' | paste -sd ', ' -)
GORELEASER_BODY=$(gh release view "$TAG" --json body -q .body)
export GORELEASER_BODY CONTRIBUTORS
envsubst '${GORELEASER_BODY} ${CONTRIBUTORS}' < .github/RELEASE_TEMPLATE.md > release-notes.md
gh release edit "$TAG" --notes-file release-notes.md
rm -f release-notes.md