Skip to content

Commit d511c26

Browse files
committed
fix: ci build
1 parent c32d1f3 commit d511c26

File tree

3 files changed

+4821
-47
lines changed

3 files changed

+4821
-47
lines changed

.github/workflows/release.yml

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,52 @@ jobs:
1414
strategy:
1515
matrix:
1616
target:
17-
[
18-
x86_64-unknown-linux-gnu,
19-
x86_64-pc-windows-gnu,
20-
x86_64-apple-darwin,
21-
aarch64-apple-darwin,
22-
]
23-
name: [commit-boost-cli, commit-boost-pbs, commit-boost-signer]
24-
17+
- x86_64-unknown-linux-gnu
18+
- x86_64-pc-windows-gnu
19+
# - x86_64-apple-darwin
20+
- aarch64-apple-darwin
21+
name:
22+
- commit-boost-cli
23+
- commit-boost-pbs
24+
- commit-boost-signer
2525
include:
2626
- target: x86_64-unknown-linux-gnu
2727
os: ubuntu-latest
2828
- target: x86_64-pc-windows-gnu
2929
os: windows-latest
30-
- target: x86_64-apple-darwin
31-
os: macos-latest
30+
# - target: x86_64-apple-darwin
31+
# os: macos-latest
3232
- target: aarch64-apple-darwin
3333
os: macos-latest
34-
3534
runs-on: ${{ matrix.os }}
3635
steps:
3736
- name: Checkout code
3837
uses: actions/checkout@v4
3938
with:
4039
ref: "stable"
4140

41+
- name: Cache Cargo registry
42+
uses: actions/cache@v3
43+
with:
44+
path: ~/.cargo/registry
45+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
46+
47+
- name: Cache Cargo index
48+
uses: actions/cache@v3
49+
with:
50+
path: ~/.cargo/git
51+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
52+
53+
- name: Cache Cargo build
54+
uses: actions/cache@v3
55+
with:
56+
path: target
57+
key: ${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
58+
restore-keys: |
59+
${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ matrix.name }}-
60+
${{ runner.os }}-cargo-build-${{ matrix.target }}-
61+
${{ runner.os }}-cargo-build-
62+
4263
- name: Install GNU toolchain (Windows)
4364
if: matrix.target == 'x86_64-pc-windows-gnu'
4465
uses: msys2/setup-msys2@v2
@@ -56,10 +77,7 @@ jobs:
5677
target: ${{ matrix.target }}
5778

5879
- name: Build binary
59-
uses: actions-rs/cargo@v1
60-
with:
61-
command: build
62-
args: --release --target ${{ matrix.target }} --bin ${{ matrix.name }}
80+
run: cargo build --release --target ${{ matrix.target }} --bin ${{ matrix.name }}
6381
env:
6482
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc
6583

@@ -73,18 +91,16 @@ jobs:
7391
- name: Package binary (Windows)
7492
if: runner.os == 'Windows'
7593
run: |
76-
cd target/${{ matrix.target }}/release
77-
7z a ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip ${{ matrix.name }}.exe
78-
move ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip ../../../
94+
7z a ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip target\${{ matrix.target }}\release\${{ matrix.name }}.exe
7995
80-
- name: Upload binary to release
81-
uses: softprops/action-gh-release@v2
96+
- name: Upload artifact
97+
uses: actions/upload-artifact@v3
8298
with:
83-
files: ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.gz' }}
84-
draft: true
85-
token: ${{ secrets.GITHUB_TOKEN }}
99+
name: ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}
100+
path: |
101+
${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.gz' }}
86102
87-
build-and-push-docker:
103+
build-and-push-pbs-docker:
88104
runs-on: ubuntu-latest
89105
steps:
90106
- name: Checkout code
@@ -105,17 +121,6 @@ jobs:
105121
username: ${{ github.actor }}
106122
password: ${{ secrets.GITHUB_TOKEN }}
107123

108-
- name: Prepare Docker metadata
109-
id: meta
110-
uses: docker/metadata-action@v4
111-
with:
112-
images: |
113-
ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}
114-
tags: |
115-
type=semver,pattern={{version}}
116-
type=semver,pattern={{major}}.{{minor}}
117-
type=raw,value=latest,enable={{is_default_branch}}
118-
119124
- name: Build and push PBS Docker image
120125
uses: docker/build-push-action@v6
121126
with:
@@ -125,10 +130,31 @@ jobs:
125130
tags: |
126131
ghcr.io/commit-boost/pbs:${{ github.ref_name }}
127132
ghcr.io/commit-boost/pbs:latest
128-
cache-from: type=gha
129-
cache-to: type=gha,mode=max
133+
cache-from: type=registry,ref=ghcr.io/commit-boost/pbs:buildcache
134+
cache-to: type=registry,ref=ghcr.io/commit-boost/pbs:buildcache,mode=max
130135
file: docker/pbs.Dockerfile
131136

137+
build-and-push-signer-docker:
138+
runs-on: ubuntu-latest
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
with:
143+
ref: "stable"
144+
145+
- name: Set up QEMU
146+
uses: docker/setup-qemu-action@v3
147+
148+
- name: Set up Docker Buildx
149+
uses: docker/setup-buildx-action@v3
150+
151+
- name: Login to GitHub Container Registry
152+
uses: docker/login-action@v3
153+
with:
154+
registry: ghcr.io
155+
username: ${{ github.actor }}
156+
password: ${{ secrets.GITHUB_TOKEN }}
157+
132158
- name: Build and push Signer Docker image
133159
uses: docker/build-push-action@v6
134160
with:
@@ -138,18 +164,29 @@ jobs:
138164
tags: |
139165
ghcr.io/commit-boost/signer:${{ github.ref_name }}
140166
ghcr.io/commit-boost/signer:latest
141-
cache-from: type=gha
142-
cache-to: type=gha,mode=max
143-
file: docker/pbs.Dockerfile
167+
cache-from: type=registry,ref=ghcr.io/commit-boost/signer:buildcache
168+
cache-to: type=registry,ref=ghcr.io/commit-boost/signer:buildcache,mode=max
169+
file: docker/signer.Dockerfile
144170

145171
finalize-release:
146-
needs: [build-binaries, build-and-push-docker]
172+
needs:
173+
- build-binaries
174+
- build-and-push-pbs-docker
175+
- build-and-push-signer-docker
147176
runs-on: ubuntu-latest
148177
steps:
178+
- name: Download artifacts
179+
uses: actions/download-artifact@v3
180+
with:
181+
path: ./artifacts
182+
149183
- name: Finalize Release
150184
uses: softprops/action-gh-release@v2
151185
with:
152-
name: ${{ github.ref_name }}
153-
tag_name: ${{ github.ref_name }}
186+
files: ./artifacts/**/*
154187
draft: true
155188
prerelease: false
189+
tag_name: ${{ github.ref_name }}
190+
name: ${{ github.ref_name }}
191+
env:
192+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
debug/
44
target/
55

6-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8-
Cargo.lock
9-
106
# These are backup files generated by rustfmt
117
**/*.rs.bk
128

0 commit comments

Comments
 (0)