-
-
Notifications
You must be signed in to change notification settings - Fork 8
211 lines (179 loc) · 5.87 KB
/
release.yml
File metadata and controls
211 lines (179 loc) · 5.87 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
name: Release
on:
push:
branches:
- master
env:
BIN_NAME: web
PROJECT_NAME: web
REPO_NAME: blueprintframework/web
NUXT_PUBLIC_TURNSTILE_SITE_KEY: ${{ secrets.NUXT_PUBLIC_TURNSTILE_SITE_KEY }}
jobs:
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install frontend dependencies
run: |
cd ./apps/frontend
pnpm install
- name: Build frontend
run: |
cd ./apps/frontend
pnpm generate
- name: Upload frontend build
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: apps/frontend/.output/public
dist:
name: Dist
needs: [build-frontend]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build: [x86_64-linux, aarch64-linux]
include:
- build: x86_64-linux
os: ubuntu-24.04
rust: stable
target: x86_64-unknown-linux-musl
cross: true
- build: aarch64-linux
os: ubuntu-24.04
rust: stable
target: aarch64-unknown-linux-musl
cross: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download frontend build
uses: actions/download-artifact@v4
with:
name: frontend-build
path: apps/frontend/.output/public
- name: Install ${{ matrix.rust }} toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: ${{ runner.os }}-${{ matrix.rust }}-${{ matrix.target }}
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: test
args: --release --target ${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --release --target ${{ matrix.target }}
- name: Prepare binary with platform name
shell: bash
run: |
mkdir -p dist
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/$BIN_NAME-${{ matrix.build }}"
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ matrix.build }}
path: dist/${{ env.BIN_NAME }}-${{ matrix.build }}
publish:
name: Publish
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: ${{ env.BIN_NAME }}*
- name: Get cli version from Cargo.toml
id: version
run: echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/*/*
file_glob: true
tag: ${{ steps.version.outputs.val }}
overwrite: true
create-multiarch-image:
name: Create multi-arch Docker image
needs: [dist]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare binaries
run: |
chmod +x dist/${{ env.PROJECT_NAME }}-x86_64-linux/${{ env.BIN_NAME }}-x86_64-linux
chmod +x dist/${{ env.PROJECT_NAME }}-aarch64-linux/${{ env.BIN_NAME }}-aarch64-linux
mkdir -p .docker/amd64 .docker/arm64
cp dist/${{ env.BIN_NAME }}-x86_64-linux/${{ env.BIN_NAME }}-x86_64-linux .docker/amd64/web
cp dist/${{ env.BIN_NAME }}-aarch64-linux/${{ env.BIN_NAME }}-aarch64-linux .docker/arm64/web
- name: Get cli version from Cargo.toml
id: version
run: echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
- name: Build and push multi-arch Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_NAME }}:latest,ghcr.io/${{ env.REPO_NAME }}:${{ steps.version.outputs.val }}
cache-from: type=gha
cache-to: type=gha,mode=max