-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (202 loc) · 7.1 KB
/
Copy pathrelease.yml
File metadata and controls
239 lines (202 loc) · 7.1 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
231
232
233
234
235
236
237
238
239
name: Release
on:
push:
tags:
- '[0-9]*.[0-9]*.[0-9]*'
permissions:
contents: read
jobs:
release:
name: Build and publish release artifacts
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run Go tests
run: go test ./...
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
- name: Validate TypeScript package
run: |
npm --prefix packages/ts ci
npm --prefix packages/ts test
npm --prefix packages/ts run build
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Run Python package tests
run: PYTHONPATH=packages/python python -m unittest discover -s packages/python/tests
- name: Validate Docker Compose config
run: |
set -euo pipefail
if docker compose version >/dev/null 2>&1; then
docker compose -f deploy/compose.yaml config >/dev/null
else
echo "Docker Compose is unavailable; skipping compose config validation."
fi
- name: Build release artifacts
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
commands=(edge-gateway private-connector signurl)
targets=(
linux/amd64
linux/arm64
darwin/amd64
darwin/arm64
windows/amd64
windows/arm64
)
mkdir -p build dist
for command in "${commands[@]}"; do
for target in "${targets[@]}"; do
goos="${target%/*}"
goarch="${target#*/}"
extension=""
if [[ "${goos}" == "windows" ]]; then
extension=".exe"
fi
binary_path="build/${command}-${goos}-${goarch}${extension}"
archive_name="air3-${command}-${TAG_NAME}-${goos}-${goarch}.tar.gz"
package_dir="$(mktemp -d)"
echo "Building ${command} for ${goos}/${goarch}"
env CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" \
go build -trimpath -ldflags="-s -w" -o "${binary_path}" "./cmd/${command}"
cp "${binary_path}" "${package_dir}/${command}${extension}"
tar -C "${package_dir}" -czf "dist/${archive_name}" "${command}${extension}"
rm -rf "${package_dir}"
done
done
- name: Generate checksums
run: |
set -euo pipefail
cd dist
sha256sum *.tar.gz > SHA256SUMS
- name: Upload workflow artifacts
uses: actions/upload-artifact@v4
with:
name: air3-${{ github.ref_name }}-release-artifacts
path: dist/*
if-no-files-found: error
- name: Create or update GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
gh release edit "${TAG_NAME}" --title "${TAG_NAME}" --notes "Release ${TAG_NAME}"
gh release upload "${TAG_NAME}" dist/* --clobber
else
gh release create "${TAG_NAME}" dist/* --title "${TAG_NAME}" --notes "Release ${TAG_NAME}"
fi
npm-package:
name: Publish TypeScript package
runs-on: ubuntu-latest
needs: release
permissions:
contents: read
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js for npmjs
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: packages/ts/package-lock.json
- name: Install TypeScript package dependencies
run: npm --prefix packages/ts ci
- name: Test and build TypeScript package
run: |
npm --prefix packages/ts test
npm --prefix packages/ts run build
- name: Check whether npm package version already exists
id: npm_version
working-directory: packages/ts
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
package_name="$(node -p "require('./package.json').name")"
if npm view "${package_name}@${TAG_NAME}" version --registry=https://registry.npmjs.org >/dev/null 2>&1; then
echo "exists=true" >> "${GITHUB_OUTPUT}"
echo "${package_name}@${TAG_NAME} already exists; skipping publish."
else
echo "exists=false" >> "${GITHUB_OUTPUT}"
fi
- name: Set TypeScript package version from tag
if: steps.npm_version.outputs.exists != 'true'
working-directory: packages/ts
env:
TAG_NAME: ${{ github.ref_name }}
run: npm version "${TAG_NAME}" --no-git-tag-version
- name: Publish TypeScript package to npmjs
if: steps.npm_version.outputs.exists != 'true'
working-directory: packages/ts
run: npm publish --access public --registry=https://registry.npmjs.org
docker-images:
name: Build and publish ${{ matrix.app }} image
runs-on: ubuntu-latest
needs: release
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
app:
- edge-gateway
- private-connector
- signurl
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare image name
id: image
env:
REPOSITORY: ${{ github.repository }}
APP: ${{ matrix.app }}
run: |
set -euo pipefail
repository="${REPOSITORY,,}"
echo "name=ghcr.io/${repository}/${APP}" >> "${GITHUB_OUTPUT}"
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
APP=${{ matrix.app }}
tags: |
${{ steps.image.outputs.name }}:${{ github.ref_name }}
labels: |
org.opencontainers.image.title=air3 ${{ matrix.app }}
org.opencontainers.image.description=air3 ${{ matrix.app }} release image
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.ref_name }}