@@ -10,24 +10,99 @@ permissions:
1010 packages : write
1111
1212jobs :
13- build-binaries :
13+ # Builds the x64 and arm64 binaries for Linux, for all 3 crates, via the Docker builder
14+ build-binaries-linux :
1415 strategy :
1516 matrix :
1617 target :
17- - x86_64-unknown-linux-gnu
18+ - amd64
19+ - arm64
20+ name :
21+ - commit-boost-cli
22+ - commit-boost-pbs
23+ - commit-boost-signer
24+ include :
25+ - target : amd64
26+ package-suffix : x86-64
27+ - target : arm64
28+ package-suffix : arm64
29+ - name : commit-boost-cli
30+ target-crate : cli
31+ - name : commit-boost-pbs
32+ target-crate : pbs
33+ - name : commit-boost-signer
34+ target-crate : signer
35+ runs-on : ubuntu-latest
36+ steps :
37+ - name : Checkout code
38+ uses : actions/checkout@v4
39+ with :
40+ ref : " stable"
41+ fetch-depth : 0
42+ submodules : true
43+
44+ - name : Log commit hash
45+ run : |
46+ echo "Releasing commit: $(git rev-parse HEAD)"
47+
48+ - name : Set up QEMU
49+ uses : docker/setup-qemu-action@v3
50+
51+ - name : Set up Docker Buildx
52+ uses : docker/setup-buildx-action@v3
53+
54+ - name : Login to GitHub Container Registry
55+ uses : docker/login-action@v3
56+ with :
57+ registry : ghcr.io
58+ username : ${{ github.actor }}
59+ password : ${{ secrets.GITHUB_TOKEN }}
60+
61+ - name : Build binary (Linux)
62+ uses : docker/build-push-action@v6
63+ with :
64+ context : .
65+ push : false
66+ platforms : linux/amd64,linux/arm64
67+ cache-from : type=registry,ref=ghcr.io/commit-boost/buildcache:${{ matrix.target-crate}}
68+ cache-to : type=registry,ref=ghcr.io/commit-boost/buildcache:${{ matrix.target-crate }},mode=max
69+ file : provisioning/build.Dockerfile
70+ outputs : type=local,dest=build
71+ build-args : |
72+ TARGET_CRATE=${{ matrix.name }}
73+
74+ - name : Package binary (Linux)
75+ run : |
76+ cd build/linux_${{ matrix.target }}
77+ tar -czvf ${{ matrix.name }}-${{ github.ref_name }}-linux_${{ matrix.package-suffix }}.tar.gz ${{ matrix.name }}
78+ mv ${{ matrix.name }}-${{ github.ref_name }}-linux_${{ matrix.package-suffix }}.tar.gz ../../
79+
80+ - name : Upload artifact
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : ${{ matrix.name }}-${{ github.ref_name }}-linux_${{ matrix.package-suffix }}
84+ path : |
85+ ${{ matrix.name }}-${{ github.ref_name }}-linux_${{ matrix.package-suffix }}.tar.gz
86+
87+ # Builds the arm64 binaries for Darwin, for all 3 crates, natively
88+ build-binaries-darwin :
89+ strategy :
90+ matrix :
91+ target :
92+ # x64 requires macos-latest-large which is not available in the free tier
1893 # - x86_64-apple-darwin
1994 - aarch64-apple-darwin
2095 name :
2196 - commit-boost-cli
2297 - commit-boost-pbs
2398 - commit-boost-signer
2499 include :
25- - target : x86_64-unknown-linux-gnu
26- os : ubuntu-latest
27100 # - target: x86_64-apple-darwin
28- # os: macos-latest
101+ # os: macos-latest-large
102+ # package-suffix: x86-64
29103 - target : aarch64-apple-darwin
30104 os : macos-latest
105+ package-suffix : arm64
31106 runs-on : ${{ matrix.os }}
32107 steps :
33108 - name : Checkout code
@@ -41,6 +116,12 @@ jobs:
41116 run : |
42117 echo "Releasing commit: $(git rev-parse HEAD)"
43118
119+ - name : Install Protoc
120+ run :
121+ # Brew's version is much more up to date than the Linux ones, and installing the latest via script runs into curl issues so for now, brew's easier to use
122+ # provisioning/protoc.sh
123+ brew install protobuf
124+
44125 - name : Cache Cargo registry
45126 uses : actions/cache@v3
46127 with :
@@ -63,48 +144,25 @@ jobs:
63144 ${{ runner.os }}-cargo-build-${{ matrix.target }}-
64145 ${{ runner.os }}-cargo-build-
65146
66- - name : Install protoc (Ubuntu)
67- if : runner.os == 'Linux'
68- run : sudo apt-get install protobuf-compiler
69-
70- - name : Install protoc (macOS)
71- if : runner.os == 'macOS'
72- run : brew install protobuf
73-
74- - name : Set up Rust
75- uses : actions-rs/toolchain@v1
76- with :
77- profile : minimal
78- toolchain : stable
79- override : true
80- target : ${{ matrix.target }}
81-
82- - name : Build binary
147+ - name : Build binary (Darwin)
83148 run : cargo build --release --target ${{ matrix.target }} --bin ${{ matrix.name }}
84- env :
85- CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER : gcc
86149
87- - name : Package binary (Unix)
88- if : runner.os != 'Windows'
150+ - name : Package binary (Darwin)
89151 run : |
90152 cd target/${{ matrix.target }}/release
91- tar -czvf ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ${{ matrix.name }}
92- mv ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ../../../
93-
94- - name : Package binary (Windows)
95- if : runner.os == 'Windows'
96- run : |
97- 7z a ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip target\${{ matrix.target }}\release\${{ matrix.name }}.exe
153+ tar -czvf ${{ matrix.name }}-${{ github.ref_name }}-darwin_${{ matrix.package-suffix }}.tar.gz ${{ matrix.name }}
154+ mv ${{ matrix.name }}-${{ github.ref_name }}-darwin_${{ matrix.package-suffix }}.tar.gz ../../../
98155
99156 - name : Upload artifact
100157 uses : actions/upload-artifact@v4
101158 with :
102- name : ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}
159+ name : ${{ matrix.name }}-${{ github.ref_name }}-darwin_ ${{ matrix.package-suffix }}
103160 path : |
104- ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || ' tar.gz' }}
161+ ${{ matrix.name }}-${{ github.ref_name }}-darwin_ ${{ matrix.package-suffix }}.tar.gz
105162
163+ # Builds the PBS Docker image
106164 build-and-push-pbs-docker :
107- needs : [build-binaries]
165+ needs : [build-binaries-linux ]
108166 runs-on : ubuntu-latest
109167 steps :
110168 - name : Checkout code
@@ -114,6 +172,20 @@ jobs:
114172 fetch-depth : 0
115173 submodules : true
116174
175+ - name : Download binary archives
176+ uses : actions/download-artifact@v4
177+ with :
178+ path : ./artifacts
179+ pattern : " commit-boost-*"
180+
181+ - name : Extract binaries
182+ run : |
183+ mkdir -p ./artifacts/bin
184+ tar -xzf ./artifacts/commit-boost-pbs-${{ github.ref_name }}-linux_x86-64/commit-boost-pbs-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
185+ mv ./artifacts/bin/commit-boost-pbs ./artifacts/bin/commit-boost-pbs-linux-amd64
186+ tar -xzf ./artifacts/commit-boost-pbs-${{ github.ref_name }}-linux_arm64/commit-boost-pbs-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
187+ mv ./artifacts/bin/commit-boost-pbs ./artifacts/bin/commit-boost-pbs-linux-arm64
188+
117189 - name : Set up QEMU
118190 uses : docker/setup-qemu-action@v3
119191
@@ -133,15 +205,16 @@ jobs:
133205 context : .
134206 push : true
135207 platforms : linux/amd64,linux/arm64
208+ build-args : |
209+ BINARIES_PATH=./artifacts/bin
136210 tags : |
137211 ghcr.io/commit-boost/pbs:${{ github.ref_name }}
138212 ${{ !contains(github.ref_name, 'rc') && 'ghcr.io/commit-boost/pbs:latest' || '' }}
139- cache-from : type=registry,ref=ghcr.io/commit-boost/pbs:buildcache
140- cache-to : type=registry,ref=ghcr.io/commit-boost/pbs:buildcache,mode=max
141213 file : provisioning/pbs.Dockerfile
142214
215+ # Builds the Signer Docker image
143216 build-and-push-signer-docker :
144- needs : [build-binaries]
217+ needs : [build-binaries-linux ]
145218 runs-on : ubuntu-latest
146219 steps :
147220 - name : Checkout code
@@ -151,6 +224,20 @@ jobs:
151224 fetch-depth : 0
152225 submodules : true
153226
227+ - name : Download binary archives
228+ uses : actions/download-artifact@v4
229+ with :
230+ path : ./artifacts
231+ pattern : " commit-boost-*"
232+
233+ - name : Extract binaries
234+ run : |
235+ mkdir -p ./artifacts/bin
236+ tar -xzf ./artifacts/commit-boost-signer-${{ github.ref_name }}-linux_x86-64/commit-boost-signer-${{ github.ref_name }}-linux_x86-64.tar.gz -C ./artifacts/bin
237+ mv ./artifacts/bin/commit-boost-signer ./artifacts/bin/commit-boost-signer-linux-amd64
238+ tar -xzf ./artifacts/commit-boost-signer-${{ github.ref_name }}-linux_arm64/commit-boost-signer-${{ github.ref_name }}-linux_arm64.tar.gz -C ./artifacts/bin
239+ mv ./artifacts/bin/commit-boost-signer ./artifacts/bin/commit-boost-signer-linux-arm64
240+
154241 - name : Set up QEMU
155242 uses : docker/setup-qemu-action@v3
156243
@@ -170,16 +257,18 @@ jobs:
170257 context : .
171258 push : true
172259 platforms : linux/amd64,linux/arm64
260+ build-args : |
261+ BINARIES_PATH=./artifacts/bin
173262 tags : |
174263 ghcr.io/commit-boost/signer:${{ github.ref_name }}
175264 ${{ !contains(github.ref_name, 'rc') && 'ghcr.io/commit-boost/signer:latest' || '' }}
176- cache-from : type=registry,ref=ghcr.io/commit-boost/signer:buildcache
177- cache-to : type=registry,ref=ghcr.io/commit-boost/signer:buildcache,mode=max
178265 file : provisioning/signer.Dockerfile
179266
267+ # Creates a draft release on GitHub with the binaries
180268 finalize-release :
181269 needs :
182- - build-binaries
270+ - build-binaries-linux
271+ - build-binaries-darwin
183272 - build-and-push-pbs-docker
184273 - build-and-push-signer-docker
185274 runs-on : ubuntu-latest
0 commit comments