-
Notifications
You must be signed in to change notification settings - Fork 15
304 lines (264 loc) · 9.72 KB
/
Copy pathrelease.yml
File metadata and controls
304 lines (264 loc) · 9.72 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (e.g. v0.1.0). Leave empty when triggered by tag push."
required: false
default: ""
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
NODE_VERSION: "20"
PNPM_VERSION: "9"
jobs:
meta:
name: Prepare release metadata
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
version: ${{ steps.tag.outputs.version }}
steps:
- name: Determine tag
id: tag
run: |
set -euo pipefail
if [ -n "${{ inputs.tag }}" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
# Strip leading "v" for version, if present
VERSION="${TAG#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Using tag: ${TAG}"
echo "Version: ${VERSION}"
build-binaries:
name: Build binaries (${{ matrix.target }})
needs: [meta]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_ext: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
artifact_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build signia CLI (release)
shell: bash
run: |
set -euo pipefail
cargo build --release --locked --target "${{ matrix.target }}" --manifest-path crates/signia-cli/Cargo.toml
- name: Build signia API (release)
shell: bash
run: |
set -euo pipefail
cargo build --release --locked --target "${{ matrix.target }}" --manifest-path crates/signia-api/Cargo.toml
- name: Package artifacts (unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
TAG="${{ needs.meta.outputs.tag }}"
TARGET="${{ matrix.target }}"
OUT="dist/${TAG}/${TARGET}"
mkdir -p "${OUT}"
cp "crates/signia-cli/target/${TARGET}/release/signia" "${OUT}/signia"
# API binary name depends on your Cargo.toml; adjust if different.
# Default assumed: signia-api
cp "crates/signia-api/target/${TARGET}/release/signia-api" "${OUT}/signia-api"
# Include licenses and notices
cp LICENSE "${OUT}/LICENSE"
if [ -f NOTICE ]; then cp NOTICE "${OUT}/NOTICE"; fi
if [ -f README.md ]; then cp README.md "${OUT}/README.md"; fi
(cd "dist/${TAG}" && tar -czf "signia-${TAG}-${TARGET}.tar.gz" "${TARGET}")
- name: Package artifacts (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$tag = "${{ needs.meta.outputs.tag }}"
$target = "${{ matrix.target }}"
$out = "dist/$tag/$target"
New-Item -ItemType Directory -Force -Path $out | Out-Null
Copy-Item "crates/signia-cli/target/$target/release/signia.exe" "$out/signia.exe"
Copy-Item "crates/signia-api/target/$target/release/signia-api.exe" "$out/signia-api.exe"
Copy-Item "LICENSE" "$out/LICENSE"
if (Test-Path "NOTICE") { Copy-Item "NOTICE" "$out/NOTICE" }
if (Test-Path "README.md") { Copy-Item "README.md" "$out/README.md" }
Compress-Archive -Path "dist/$tag/$target" -DestinationPath "dist/$tag/signia-$tag-$target.zip" -Force
- name: Generate checksums (unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
TAG="${{ needs.meta.outputs.tag }}"
cd "dist/${TAG}"
shasum -a 256 "signia-${TAG}-${{ matrix.target }}.${{ matrix.artifact_ext }}" > "signia-${TAG}-${{ matrix.target }}.${{ matrix.artifact_ext }}.sha256"
- name: Generate checksums (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$tag = "${{ needs.meta.outputs.tag }}"
$target = "${{ matrix.target }}"
$file = "dist/$tag/signia-$tag-$target.zip"
$hash = (Get-FileHash -Algorithm SHA256 $file).Hash.ToLower()
"$hash signia-$tag-$target.zip" | Out-File -FilePath "dist/$tag/signia-$tag-$target.zip.sha256" -Encoding ascii
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.target }}
path: dist/${{ needs.meta.outputs.tag }}/*
if-no-files-found: error
github-release:
name: Create GitHub Release
needs: [meta, build-binaries]
runs-on: ubuntu-latest
steps:
- name: Download all dist artifacts
uses: actions/download-artifact@v4
with:
path: dist-merge
- name: Flatten dist directory
run: |
set -euo pipefail
TAG="${{ needs.meta.outputs.tag }}"
mkdir -p "release-dist/${TAG}"
find dist-merge -type f -name "signia-${TAG}-*.tar.gz" -exec cp {} "release-dist/${TAG}/" \;
find dist-merge -type f -name "signia-${TAG}-*.zip" -exec cp {} "release-dist/${TAG}/" \;
find dist-merge -type f -name "*.sha256" -exec cp {} "release-dist/${TAG}/" \;
ls -la "release-dist/${TAG}"
- name: Generate release notes (basic)
run: |
set -euo pipefail
TAG="${{ needs.meta.outputs.tag }}"
cat > RELEASE_NOTES.md <<EOF
SIGNIA ${TAG}
Assets:
- signia (CLI)
- signia-api (API service)
- SHA256 checksums included
Notes:
- This release is built from tag ${TAG}.
EOF
- name: Publish GitHub Release and upload assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.meta.outputs.tag }}
name: SIGNIA ${{ needs.meta.outputs.tag }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
files: |
release-dist/${{ needs.meta.outputs.tag }}/signia-${{ needs.meta.outputs.tag }}-*.tar.gz
release-dist/${{ needs.meta.outputs.tag }}/signia-${{ needs.meta.outputs.tag }}-*.zip
release-dist/${{ needs.meta.outputs.tag }}/*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Build and push Docker images (optional)
needs: [meta, github-release]
runs-on: ubuntu-latest
if: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push API image
uses: docker/build-push-action@v6
with:
context: .
file: infra/docker/api.Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/signia-api:${{ needs.meta.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/signia-api:latest
- name: Build and push Console image
uses: docker/build-push-action@v6
with:
context: .
file: infra/docker/console.Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/signia-console:${{ needs.meta.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/signia-console:latest
- name: Build and push Interface image
uses: docker/build-push-action@v6
with:
context: .
file: infra/docker/interface.Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/signia-interface:${{ needs.meta.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/signia-interface:latest
npm:
name: Publish npm packages (optional)
needs: [meta, github-release]
runs-on: ubuntu-latest
if: ${{ secrets.NPM_TOKEN != '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: |
set -euo pipefail
if [ -d "sdk/ts" ]; then
(cd sdk/ts && pnpm install --frozen-lockfile || true)
(cd sdk/ts && (pnpm run build || true))
fi
- name: Publish sdk/ts (if configured)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -euo pipefail
if [ -f "sdk/ts/package.json" ]; then
cd sdk/ts
# Ensure package.json has proper name/version and "publishConfig" if needed.
npm publish --access public || npm publish
else
echo "sdk/ts/package.json not found; skipping."
fi