Repository navigation
Expand file tree
/
Copy pathrelease-binary-and-wrapper.yaml
More file actions
231 lines (205 loc) · 8.22 KB
/
Copy pathrelease-binary-and-wrapper.yaml
File metadata and controls
231 lines (205 loc) · 8.22 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Creates GitHub releases with multi-platform CodingBooth binaries, wrapper, and examples.
# Triggers on: manual dispatch only.
name: Release CodingBooth
on:
workflow_dispatch:
# Callable from `release-all.yaml`, which must grant contents: write --
# a caller caps a callee's permissions, it cannot widen them.
workflow_call:
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
# ---------------------------------------------------------
# Checkout and Setup
# ---------------------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
with:
# Full history and tags: the catalog version check compares against the
# manifest at the previous release tag.
fetch-depth: 0
- name: Set up Go
run: |
./build/init-go-setup.sh
echo "/usr/local/go/bin" >> $GITHUB_PATH
# ---------------------------------------------------------
# Read version.txt → output "version"
# ---------------------------------------------------------
- name: Read version from version.txt
id: get_version
run: |
set -euo pipefail
VERSION=$(tr -d ' \t\r\n' < version.txt)
if [ -z "$VERSION" ]; then
echo "version.txt is empty" >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Show version
run: echo "Publishing CodingBooth for version ${{ steps.get_version.outputs.version }}"
- name: Reject pre-release (--rc) versions
run: |
set -euo pipefail
VERSION="${{ steps.get_version.outputs.version }}"
if [[ "$VERSION" =~ --rc([0-9]+)?$ ]]; then
echo "::error::Refusing to release pre-release version '$VERSION'. Binary releases are only allowed for stable (non-rc) versions."
exit 1
fi
echo "Stable version — proceeding."
- name: Verify README version matches version.txt
run: |
set -euo pipefail
VERSION="${{ steps.get_version.outputs.version }}"
README_VERSION=$(grep -oP '(?<=\*\*Current Version:\*\* v)[^ ]+' README.md)
if [ "$VERSION" != "$README_VERSION" ]; then
echo "::error::Version mismatch — version.txt: $VERSION, README.md: $README_VERSION"
exit 1
fi
echo "Versions match: $VERSION"
# ---------------------------------------------------------
# Cleanup old untagged releases
# ---------------------------------------------------------
- name: Delete untagged releases
run: |
set -euo pipefail
gh release list --limit 100 --json tagName \
--jq '.[] | select(.tagName | startswith("untagged-")) | .tagName' \
| xargs -r -I {} gh release delete {} -y
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---------------------------------------------------------
# Build binary artifacts
# ---------------------------------------------------------
- name: Build Go binaries for all platforms
run: |
./build/cli-build.sh
ls -la bin
- name: Make wrapper executable
run: chmod +x booth
- name: Generate SHA256 checksums for all binaries
run: |
cd bin
echo "BIN"
ls -la
for binary in codingbooth-*; do
sha256sum "$binary" > "${binary}.sha256"
done
cd ..
echo "ROOT"
ls -la
# ---------------------------------------------------------
# Build example artifacts
# ---------------------------------------------------------
- name: Update booth wrappers
run: |
cd ./examples
./update-booth.sh
cd ..
- name: Create example-list.txt
run: |
echo "# CodingBooth Examples" > example-list.txt
echo "" >> example-list.txt
echo "## Workspace Examples" >> example-list.txt
for dir in examples/workspaces/*-example/; do
name=$(basename "$dir")
echo "- $name" >> example-list.txt
done
echo "" >> example-list.txt
echo "## Demo" >> example-list.txt
echo "- demo" >> example-list.txt
- name: Package workspace examples
run: |
mkdir -p dist
cd examples/workspaces
for dir in *-example/; do
name=$(basename "$dir")
zip -r "../../dist/${name}.zip" "$dir"
done
- name: Package demo
run: |
cd examples
zip -r ../dist/demo.zip demo/
- name: Move example-list.txt to dist
run: mv example-list.txt dist/
# ---------------------------------------------------------
# Build template artifacts
# ---------------------------------------------------------
# Every catalog item that changed since the previous release must have
# bumped its cb-version (docs/CATALOG_VERSIONING.md). Refuse to publish otherwise.
- name: Check catalog item versions
run: ./build/check-catalog-versions.sh
# No test fixture or example may carry a copy of a built-in setup in its
# .booth/setups/: the copy runs instead of what the image ships, so the
# test stops testing the catalog. Refuse to publish otherwise.
- name: Check no .booth/setups/ shadows a built-in
run: ./build/check-setup-shadowing.sh
- name: Package templates
run: |
zip -r dist/templates.zip templates/
# Published beside the templates: what each catalog item was in this release.
cp build/catalog-manifest.tsv dist/catalog-manifest.tsv
# ---------------------------------------------------------
# Publish versioned release (binary + examples)
# ---------------------------------------------------------
- name: Publish versioned release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
name: ${{ steps.get_version.outputs.version }}
body: |
CodingBooth ${{ steps.get_version.outputs.version }}
Multi-platform binaries and example workspaces.
prerelease: false
files: |
bin/codingbooth-linux-amd64
bin/codingbooth-linux-amd64.sha256
bin/codingbooth-linux-arm64
bin/codingbooth-linux-arm64.sha256
bin/codingbooth-darwin-amd64
bin/codingbooth-darwin-amd64.sha256
bin/codingbooth-darwin-arm64
bin/codingbooth-darwin-arm64.sha256
bin/codingbooth-windows-amd64.exe
bin/codingbooth-windows-amd64.exe.sha256
bin/codingbooth-windows-arm64.exe
bin/codingbooth-windows-arm64.exe.sha256
booth
version.txt
dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ---------------------------------------------------------
# Publish latest release (stable only, replaces on each run)
# ---------------------------------------------------------
- name: Publish latest release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
name: latest
body: |
CodingBooth ${{ steps.get_version.outputs.version }}
Multi-platform binaries and example workspaces.
This release is updated with each stable version.
prerelease: false
draft: false
files: |
bin/codingbooth-linux-amd64
bin/codingbooth-linux-amd64.sha256
bin/codingbooth-linux-arm64
bin/codingbooth-linux-arm64.sha256
bin/codingbooth-darwin-amd64
bin/codingbooth-darwin-amd64.sha256
bin/codingbooth-darwin-arm64
bin/codingbooth-darwin-arm64.sha256
bin/codingbooth-windows-amd64.exe
bin/codingbooth-windows-amd64.exe.sha256
bin/codingbooth-windows-arm64.exe
bin/codingbooth-windows-arm64.exe.sha256
booth
version.txt
dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}