Repository navigation
222 lines (216 loc) · 8.63 KB
/
Copy pathrelease.yml
File metadata and controls
222 lines (216 loc) · 8.63 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
name: Release Tuxee
on:
push:
tags: ['v*']
permissions:
contents: read
concurrency:
group: tuxee-release
cancel-in-progress: false
env:
IMAGE: ${{ vars.DOCKERHUB_IMAGE || 'agent0ai/tuxee' }}
TAG: ${{ github.ref_name }}
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate release inputs
env:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
DOCKERHUB_OAT_TOKEN: ${{ secrets.DOCKERHUB_OAT_TOKEN }}
run: |
python3 .github/release-notes.py "$TAG" > /tmp/release-notes.md
test -n "$DOCKERHUB_ORG" && test -n "$DOCKERHUB_OAT_TOKEN" || {
echo "::error::Set DOCKERHUB_ORG and DOCKERHUB_OAT_TOKEN repository secrets."
exit 1
}
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
- name: Verify
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libpam0g-dev musl-tools
npm ci
npm run build
make -C internal/keeper/native
mkdir -p bin
go build -o bin/tuxee ./cmd/tuxee
go build -ldflags='-X main.version=0.2.1' -o bin/tuxee-setup ./cmd/tuxee
sudo env TUXEE_SETUP_TEST_BINARY="$PWD/bin/tuxee-setup" python3 tests/setup.py
go test ./internal/... ./cmd/... ./tests
sudo env GOMAXPROCS=2 "$(command -v go)" test -p 2 ./internal/... ./cmd/... ./tests
sudo env TUXEE_SYSTEM_TEST=1 GOMAXPROCS=2 "$(command -v go)" test -p 2 ./internal/identity ./tests
go vet ./internal/... ./cmd/... ./tests
python3 .github/release-notes.py --self-test
npm run test:installer
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_ORG }}
password: ${{ secrets.DOCKERHUB_OAT_TOKEN }}
- name: Build and push native image by digest
id: image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/${{ matrix.arch }}
build-args: VERSION=${{ github.ref_name }}
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=release-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=release-${{ matrix.arch }}
- name: Export the matching release binary
uses: docker/build-push-action@v6
with:
context: .
target: binary
platforms: linux/${{ matrix.arch }}
build-args: VERSION=${{ github.ref_name }}
outputs: type=local,dest=release
cache-from: type=gha,scope=release-${{ matrix.arch }}
- name: Export the matching audio runtime
uses: docker/build-push-action@v6
with:
context: .
target: audio-runtime
platforms: linux/${{ matrix.arch }}
outputs: type=local,dest=audio-release
cache-from: type=gha,scope=release-${{ matrix.arch }}
- name: Verify image, binary and audio runtime
env:
ARCH: ${{ matrix.arch }}
DIGEST: ${{ steps.image.outputs.digest }}
run: |
mv release/tuxee "release/tuxee-linux-$ARCH"
mv audio-release/tuxee-audio.tar.gz "release/tuxee-audio-linux-$ARCH.tar.gz"
chmod +x "release/tuxee-linux-$ARCH"
test "$("release/tuxee-linux-$ARCH" version)" = "Tuxee ${TAG#v}"
# Hosted runners make /usr/local/bin world-writable for tool installation.
sudo install -d -o root -g root -m 0755 /usr/local/bin
sudo "release/tuxee-linux-$ARCH" __install
sudo "release/tuxee-linux-$ARCH" __install
test "$(/usr/local/bin/tuxee version)" = "Tuxee ${TAG#v}"
docker pull "$IMAGE@$DIGEST"
test "$(docker run --rm --entrypoint /usr/local/bin/tuxee "$IMAGE@$DIGEST" version)" = "Tuxee ${TAG#v}"
docker run --rm --entrypoint /bin/sh -v "$PWD/release:/release:ro" "$IMAGE@$DIGEST" -ec '
test "$(cat /usr/local/lib/tuxee/update-version)" = "$1"
mkdir /tmp/audio
tar -xzf "/release/tuxee-audio-linux-$2.tar.gz" -C /tmp/audio
/tmp/audio/usr/local/bin/tuxee-pulseaudio --version
/tmp/audio/usr/local/bin/tuxee-pacat --version
' -- "${TAG#v}" "$ARCH"
mkdir -p digests
touch "digests/${DIGEST#sha256:}"
- uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.arch }}
path: release/*
if-no-files-found: error
- uses: actions/upload-artifact@v4
with:
name: digest-${{ matrix.arch }}
path: digests/*
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
pattern: binary-*
path: release
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: digest-*
path: digests
merge-multiple: true
- name: Prepare release assets and notes
run: |
test -f release/tuxee-linux-amd64
test -f release/tuxee-linux-arm64
test -f release/tuxee-audio-linux-amd64.tar.gz
test -f release/tuxee-audio-linux-arm64.tar.gz
(cd release && sha256sum tuxee-linux-* tuxee-audio-linux-*.tar.gz > checksums.txt)
python3 .github/release-notes.py "$TAG" > release-notes.md
- name: Prepare draft
id: release
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const {owner, repo} = context.repo;
const tag = process.env.TAG;
const version = s => {
if (!/^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(s)) throw new Error('Invalid stable tag');
return s.slice(1).split('.').map(BigInt);
};
let latest = true;
try {
const current = version((await github.rest.repos.getLatestRelease({owner, repo})).data.tag_name);
const next = version(tag);
latest = next.some((n, i) => n > current[i] && next.slice(0, i).every((v, j) => v === current[j]));
} catch (error) { if (error.status !== 404) throw error; }
let release;
try {
release = (await github.rest.repos.getReleaseByTag({owner, repo, tag})).data;
if (!release.draft) throw new Error('Refusing to overwrite a published release');
} catch (error) {
if (error.status !== 404) throw error;
release = (await github.rest.repos.createRelease({
owner, repo, tag_name: tag, name: `Tuxee ${tag}`, draft: true,
body: fs.readFileSync('release-notes.md', 'utf8')
})).data;
}
core.setOutput('id', release.id);
core.setOutput('latest', String(latest));
- name: Upload verified release assets
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$TAG" release/* --clobber
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_ORG }}
password: ${{ secrets.DOCKERHUB_OAT_TOKEN }}
- name: Publish both image platforms
env:
MAKE_LATEST: ${{ steps.release.outputs.latest }}
run: |
tags=(-t "$IMAGE:$TAG" -t "$IMAGE:${TAG#v}")
if [ "$MAKE_LATEST" = true ]; then tags+=(-t "$IMAGE:latest"); fi
sources=()
for digest in digests/*; do sources+=("$IMAGE@sha256:${digest##*/}"); done
test "${#sources[@]}" -eq 2
docker buildx imagetools create "${tags[@]}" "${sources[@]}"
- name: Publish complete GitHub release
uses: actions/github-script@v8
env:
RELEASE_ID: ${{ steps.release.outputs.id }}
MAKE_LATEST: ${{ steps.release.outputs.latest }}
with:
script: |
await github.rest.repos.updateRelease({
...context.repo, release_id: Number(process.env.RELEASE_ID),
draft: false, make_latest: process.env.MAKE_LATEST
});