Skip to content

Commit ee245ca

Browse files
committed
Add tag release workflow
1 parent 6485d2d commit ee245ca

2 files changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]*.[0-9]*.[0-9]*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Build and publish release artifacts
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version-file: go.mod
24+
25+
- name: Run Go tests
26+
run: go test ./...
27+
28+
- name: Validate Docker Compose config
29+
run: |
30+
set -euo pipefail
31+
if docker compose version >/dev/null 2>&1; then
32+
docker compose -f deploy/compose.yaml config >/dev/null
33+
else
34+
echo "Docker Compose is unavailable; skipping compose config validation."
35+
fi
36+
37+
- name: Build release artifacts
38+
env:
39+
TAG_NAME: ${{ github.ref_name }}
40+
run: |
41+
set -euo pipefail
42+
43+
commands=(edge-gateway private-connector signurl)
44+
targets=(
45+
linux/amd64
46+
linux/arm64
47+
darwin/amd64
48+
darwin/arm64
49+
windows/amd64
50+
windows/arm64
51+
)
52+
53+
mkdir -p build dist
54+
55+
for command in "${commands[@]}"; do
56+
for target in "${targets[@]}"; do
57+
goos="${target%/*}"
58+
goarch="${target#*/}"
59+
extension=""
60+
if [[ "${goos}" == "windows" ]]; then
61+
extension=".exe"
62+
fi
63+
64+
binary_path="build/${command}-${goos}-${goarch}${extension}"
65+
archive_name="air3-${command}-${TAG_NAME}-${goos}-${goarch}.tar.gz"
66+
package_dir="$(mktemp -d)"
67+
68+
echo "Building ${command} for ${goos}/${goarch}"
69+
env CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" \
70+
go build -trimpath -ldflags="-s -w" -o "${binary_path}" "./cmd/${command}"
71+
72+
cp "${binary_path}" "${package_dir}/${command}${extension}"
73+
tar -C "${package_dir}" -czf "dist/${archive_name}" "${command}${extension}"
74+
rm -rf "${package_dir}"
75+
done
76+
done
77+
78+
- name: Generate checksums
79+
run: |
80+
set -euo pipefail
81+
cd dist
82+
sha256sum *.tar.gz > SHA256SUMS
83+
84+
- name: Upload workflow artifacts
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: air3-${{ github.ref_name }}-release-artifacts
88+
path: dist/*
89+
if-no-files-found: error
90+
91+
- name: Create or update GitHub Release
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
TAG_NAME: ${{ github.ref_name }}
95+
run: |
96+
set -euo pipefail
97+
98+
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
99+
gh release edit "${TAG_NAME}" --title "${TAG_NAME}" --notes "Release ${TAG_NAME}"
100+
gh release upload "${TAG_NAME}" dist/* --clobber
101+
else
102+
gh release create "${TAG_NAME}" dist/* --title "${TAG_NAME}" --notes "Release ${TAG_NAME}"
103+
fi

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ make validate # format, test, build, and validate Compose config
6161
go test ./... -race # run race-enabled Go tests (expected to pass)
6262
```
6363

64+
## Releases
65+
66+
Pushing a bare semver-like tag such as `0.0.1` runs the release workflow. The workflow tests the Go packages, validates the Compose file when Docker Compose is available, cross-compiles `edge-gateway`, `private-connector`, and `signurl` for Linux, macOS, and Windows on amd64 and arm64, uploads the packaged artifacts, and publishes them to the GitHub Release for the tag with SHA-256 checksums.
67+
6468
## Docker Compose demo quickstart
6569

6670
The demo starts four runtime services:

0 commit comments

Comments
 (0)