1+ name : Release
2+ on :
3+ push :
4+ branches :
5+ - master
6+
7+ env :
8+ BIN_NAME : web
9+ PROJECT_NAME : web
10+ REPO_NAME : blueprintframework/web
11+
12+ jobs :
13+ build-frontend :
14+ name : Build Frontend
15+ runs-on : ubuntu-latest
16+ steps :
17+ - name : Checkout sources
18+ uses : actions/checkout@v4
19+
20+ - name : Setup Node.js
21+ uses : actions/setup-node@v4
22+ with :
23+ node-version : ' 22'
24+
25+ - name : Setup pnpm
26+ uses : pnpm/action-setup@v2
27+ with :
28+ version : 8
29+ run_install : false
30+
31+ - name : Get pnpm store directory
32+ id : pnpm-cache
33+ shell : bash
34+ run : |
35+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
36+
37+ - name : Setup pnpm cache
38+ uses : actions/cache@v3
39+ with :
40+ path : ${{ steps.pnpm-cache.outputs.STORE_PATH }}
41+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42+ restore-keys : |
43+ ${{ runner.os }}-pnpm-store-
44+
45+ - name : Install frontend dependencies
46+ run : |
47+ cd ./apps/frontend
48+ pnpm install
49+
50+ - name : Build frontend
51+ run : |
52+ cd ./apps/frontend
53+ pnpm generate
54+
55+ - name : Upload frontend build
56+ uses : actions/upload-artifact@v4
57+ with :
58+ name : frontend-build
59+ path : apps/frontend/.output/public
60+
61+ dist :
62+ name : Dist
63+ needs : [build-frontend]
64+ runs-on : ${{ matrix.os }}
65+ strategy :
66+ fail-fast : false
67+ matrix :
68+ build : [x86_64-linux, aarch64-linux]
69+ include :
70+ - build : x86_64-linux
71+ os : ubuntu-24.04
72+ rust : stable
73+ target : x86_64-unknown-linux-musl
74+ cross : true
75+ - build : aarch64-linux
76+ os : ubuntu-24.04
77+ rust : stable
78+ target : aarch64-unknown-linux-musl
79+ cross : true
80+
81+ steps :
82+ - name : Checkout sources
83+ uses : actions/checkout@v4
84+
85+ - name : Download frontend build
86+ uses : actions/download-artifact@v4
87+ with :
88+ name : frontend-build
89+ path : apps/frontend/.output/public
90+
91+ - name : Install ${{ matrix.rust }} toolchain
92+ uses : actions-rs/toolchain@v1
93+ with :
94+ profile : minimal
95+ toolchain : ${{ matrix.rust }}
96+ target : ${{ matrix.target }}
97+ override : true
98+
99+ - name : Rust Cache
100+ uses : Swatinem/rust-cache@v2
101+ with :
102+ prefix-key : ${{ runner.os }}-${{ matrix.rust }}-${{ matrix.target }}
103+
104+ - name : Run cargo test
105+ uses : actions-rs/cargo@v1
106+ with :
107+ use-cross : ${{ matrix.cross }}
108+ command : test
109+ args : --release --target ${{ matrix.target }}
110+
111+ - name : Build release binary
112+ uses : actions-rs/cargo@v1
113+ with :
114+ use-cross : ${{ matrix.cross }}
115+ command : build
116+ args : --release --target ${{ matrix.target }}
117+
118+ - name : Prepare binary with platform name
119+ shell : bash
120+ run : |
121+ mkdir -p dist
122+ cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/$BIN_NAME-${{ matrix.build }}"
123+
124+ - name : Upload binary artifact
125+ uses : actions/upload-artifact@v4
126+ with :
127+ name : ${{ env.PROJECT_NAME }}-${{ matrix.build }}
128+ path : dist/${{ env.BIN_NAME }}-${{ matrix.build }}
129+
130+ publish :
131+ name : Publish
132+ needs : [dist]
133+ runs-on : ubuntu-latest
134+ permissions :
135+ contents : write
136+ steps :
137+ - name : Checkout sources
138+ uses : actions/checkout@v4
139+
140+ - name : Download all artifacts
141+ uses : actions/download-artifact@v4
142+ with :
143+ path : artifacts
144+ pattern : ${{ env.BIN_NAME }}*
145+
146+ - name : Get cli version from Cargo.toml
147+ id : version
148+ run : echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
149+
150+ - name : Upload binaries to release
151+ uses : svenstaro/upload-release-action@v2
152+ with :
153+ repo_token : ${{ secrets.GITHUB_TOKEN }}
154+ file : artifacts/*/*
155+ file_glob : true
156+ tag : ${{ steps.version.outputs.val }}
157+ overwrite : true
158+
159+ create-multiarch-image :
160+ name : Create multi-arch Docker image
161+ needs : [dist]
162+ runs-on : ubuntu-latest
163+ permissions :
164+ contents : read
165+ packages : write
166+
167+ steps :
168+ - name : Checkout code
169+ uses : actions/checkout@v4
170+
171+ - name : Download all artifacts
172+ uses : actions/download-artifact@v4
173+ with :
174+ path : dist
175+
176+ - name : Set up QEMU
177+ uses : docker/setup-qemu-action@v2
178+
179+ - name : Set up Docker Buildx
180+ uses : docker/setup-buildx-action@v2
181+
182+ - name : Login to GitHub Container Registry
183+ uses : docker/login-action@v3
184+ with :
185+ registry : ghcr.io
186+ username : ${{ github.actor }}
187+ password : ${{ secrets.GITHUB_TOKEN }}
188+
189+ - name : Prepare binaries
190+ run : |
191+ chmod +x dist/${{ env.PROJECT_NAME }}-x86_64-linux/${{ env.BIN_NAME }}-x86_64-linux
192+ chmod +x dist/${{ env.PROJECT_NAME }}-aarch64-linux/${{ env.BIN_NAME }}-aarch64-linux
193+
194+ mkdir -p .docker/amd64 .docker/arm64
195+ cp dist/${{ env.BIN_NAME }}-x86_64-linux/${{ env.BIN_NAME }}-x86_64-linux .docker/amd64/web
196+ cp dist/${{ env.BIN_NAME }}-aarch64-linux/${{ env.BIN_NAME }}-aarch64-linux .docker/arm64/web
197+
198+ - name : Get cli version from Cargo.toml
199+ id : version
200+ run : echo "val=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
201+
202+ - name : Build and push multi-arch Docker image
203+ uses : docker/build-push-action@v5
204+ with :
205+ context : .
206+ platforms : linux/amd64,linux/arm64
207+ push : true
208+ tags : ghcr.io/${{ env.REPO_NAME }}:latest,ghcr.io/${{ env.REPO_NAME }}:${{ steps.version.outputs.val }}
209+ cache-from : type=gha
210+ cache-to : type=gha,mode=max
0 commit comments