Skip to content

Commit 33646eb

Browse files
authored
ci: build image for arm64 too (#6)
* ci: build image for arm64 too * ci: update action versions
1 parent 4a0a08b commit 33646eb

File tree

1 file changed

+89
-19
lines changed

1 file changed

+89
-19
lines changed

.github/workflows/release.yml

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ env:
1212
CARGO_TERM_COLOR: always
1313

1414
jobs:
15-
build-and-release:
16-
runs-on: ubuntu-latest
17-
15+
build:
16+
strategy:
17+
matrix:
18+
include:
19+
- runner: ubuntu-latest
20+
platform: linux/amd64
21+
arch: x86_64
22+
- runner: ubuntu-24.04-arm
23+
platform: linux/arm64
24+
arch: arm64
25+
runs-on: ${{ matrix.runner }}
26+
1827
steps:
1928
- uses: actions/checkout@v4
20-
29+
2130
- name: Install protobuf compiler
2231
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
23-
32+
2433
- name: Install Rust
2534
uses: dtolnay/rust-toolchain@stable
2635
with:
@@ -38,37 +47,98 @@ jobs:
3847
with:
3948
username: ${{ secrets.DOCKERHUB_USERNAME }}
4049
password: ${{ secrets.DOCKERHUB_TOKEN }}
41-
50+
4251
- name: Cache cargo
43-
uses: actions/cache@v3
52+
uses: actions/cache@v4
4453
with:
4554
path: |
4655
~/.cargo/registry
4756
~/.cargo/git
4857
target
49-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
50-
58+
key: ${{ runner.os }}-${{ matrix.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
59+
5160
- name: Build release
5261
run: cargo build --release
5362

54-
- name: Build and push Docker image
55-
uses: docker/build-push-action@v5
63+
- name: Build and push Docker image by digest
64+
id: build
65+
uses: docker/build-push-action@v6
5666
with:
5767
context: .
68+
platforms: ${{ matrix.platform }}
5869
push: true
59-
tags: |
60-
dashpay/quorum-list-server:latest
61-
dashpay/quorum-list-server:${{ steps.meta.outputs.version }}
62-
70+
tags: dashpay/quorum-list-server
71+
outputs: type=image,push-by-digest=true,name-canonical=true
72+
73+
- name: Export digest
74+
run: |
75+
mkdir -p ${{ runner.temp }}/digests
76+
digest="${{ steps.build.outputs.digest }}"
77+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
78+
79+
- name: Upload digest
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: digests-${{ matrix.arch }}
83+
path: ${{ runner.temp }}/digests/*
84+
if-no-files-found: error
85+
retention-days: 1
86+
6387
- name: Create release archive
6488
run: |
6589
cd target/release
66-
tar -czf quorum-list-server-linux-x86_64.tar.gz quorum-list-server
67-
90+
tar -czf quorum-list-server-linux-${{ matrix.arch }}.tar.gz quorum-list-server
91+
92+
- name: Upload release archive
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: binary-${{ matrix.arch }}
96+
path: target/release/quorum-list-server-linux-${{ matrix.arch }}.tar.gz
97+
retention-days: 1
98+
99+
merge-and-release:
100+
runs-on: ubuntu-latest
101+
needs: build
102+
103+
steps:
104+
- name: Derive version from tag
105+
id: meta
106+
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
107+
108+
- name: Set up Docker Buildx
109+
uses: docker/setup-buildx-action@v3
110+
111+
- name: Log in to Docker Hub
112+
uses: docker/login-action@v3
113+
with:
114+
username: ${{ secrets.DOCKERHUB_USERNAME }}
115+
password: ${{ secrets.DOCKERHUB_TOKEN }}
116+
117+
- name: Download digests
118+
uses: actions/download-artifact@v4
119+
with:
120+
pattern: digests-*
121+
path: ${{ runner.temp }}/digests
122+
merge-multiple: true
123+
124+
- name: Create multi-platform manifest
125+
run: |
126+
docker buildx imagetools create \
127+
-t dashpay/quorum-list-server:latest \
128+
-t dashpay/quorum-list-server:${{ steps.meta.outputs.version }} \
129+
$(for f in ${{ runner.temp }}/digests/*; do echo "dashpay/quorum-list-server@sha256:$(basename $f)"; done | xargs)
130+
131+
- name: Download binaries
132+
uses: actions/download-artifact@v4
133+
with:
134+
pattern: binary-*
135+
path: ${{ runner.temp }}/binaries
136+
merge-multiple: true
137+
68138
- name: Create GitHub Release
69-
uses: softprops/action-gh-release@v1
139+
uses: softprops/action-gh-release@v2
70140
with:
71-
files: target/release/quorum-list-server-linux-x86_64.tar.gz
141+
files: ${{ runner.temp }}/binaries/*.tar.gz
72142
generate_release_notes: true
73143
env:
74144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)