-
Notifications
You must be signed in to change notification settings - Fork 18
197 lines (171 loc) · 6.08 KB
/
Copy pathrelease.yml
File metadata and controls
197 lines (171 loc) · 6.08 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
name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin, freebsd]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: server/frontend/package-lock.json
- name: Build frontend
run: |
cd server/frontend
npm ci
npm run build
- name: Build binary
run: |
mkdir -p dist
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
EXT=".exe"
fi
VERSION="${{ github.ref_name }}"
COMMIT="$(git rev-parse HEAD)"
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w -X main.Version=${VERSION} -X main.Commit=${COMMIT}" -o dist/tinyice-${{ matrix.goos }}-${{ matrix.goarch }}${EXT} main.go
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: tinyice-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
test_startup:
name: Test TinyIce Startup
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Determine Runner Architecture
id: arch_detect
run: |
RUNNER_ARCH=$(uname -m)
case "$RUNNER_ARCH" in
x86_64) GOARCH="amd64" ;;
aarch64) GOARCH="arm64" ;;
arm64) GOARCH="arm64" ;;
*) echo "Unsupported runner architecture: $RUNNER_ARCH"; exit 1 ;;
esac
echo "GOARCH=$GOARCH" >> "$GITHUB_OUTPUT"
- name: Download Linux Artifact for Runner Arch
uses: actions/download-artifact@v4
with:
name: tinyice-linux-${{ steps.arch_detect.outputs.GOARCH }}
path: artifacts_to_test
- name: Run TinyIce startup test
run: |
GOARCH="${{ steps.arch_detect.outputs.GOARCH }}"
BINARY_PATH="artifacts_to_test/tinyice-linux-${GOARCH}"
echo "Starting TinyIce in background for 5 seconds to check for startup errors..."
chmod +x "$BINARY_PATH" # Add execute permissions
# Run TinyIce, preventing set -e from failing the script immediately if timeout returns 124.
# We want to pass if it exits 0 (graceful stop) or 124 (timeout).
# We fail if it exits with any other non-zero code.
if timeout 5s sh -c "$BINARY_PATH -port 8080 -config /tmp/tinyice-test-linux-${GOARCH}.json"; then
TIMEOUT_EXIT_CODE=0 # timeout succeeded, meaning inner command exited 0
else
TIMEOUT_EXIT_CODE=$? # timeout failed (either non-zero from inner command or 124 for timeout)
fi
if [ $TIMEOUT_EXIT_CODE -eq 0 ]; then
echo "TinyIce exited gracefully within 5 seconds. Test passed."
exit 0 # Pass
elif [ $TIMEOUT_EXIT_CODE -eq 124 ]; then
echo "TinyIce ran for more than 5 seconds or was killed by timeout. Test passed (successful startup)."
exit 0 # Pass
else
echo "TinyIce exited with an unexpected error code: $TIMEOUT_EXIT_CODE within 5 seconds. This indicates a startup failure."
exit 1 # Fail
fi
release:
name: Create Release
needs: [build, test_startup]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate Checksums
run: |
cd artifacts
# Generate checksums for all binaries in subdirectories
sha256sum tinyice-*/* | sed 's|tinyice-[^/]*/||' > ../checksums.txt
cd ..
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
artifacts/**/tinyice*
checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Build and Push Docker Image
needs: test_startup
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
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 GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/tinyice
# While the project is still in beta, apply :latest to every tag
# so `docker pull ghcr.io/.../tinyice:latest` always resolves.
# Also publish a :vX.Y.Z alias alongside the stripped :X.Y.Z so
# both forms work.
flavor: |
latest=true
tags: |
type=semver,pattern={{version}}
type=semver,pattern=v{{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=beta,enable=${{ contains(github.ref_name, '-beta') }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max