Skip to content

Commit

Permalink
fix: ci build
Browse files Browse the repository at this point in the history
  • Loading branch information
ltitanb committed Oct 2, 2024
1 parent c32d1f3 commit d511c26
Show file tree
Hide file tree
Showing 3 changed files with 4,821 additions and 47 deletions.
123 changes: 80 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,52 @@ jobs:
strategy:
matrix:
target:
[
x86_64-unknown-linux-gnu,
x86_64-pc-windows-gnu,
x86_64-apple-darwin,
aarch64-apple-darwin,
]
name: [commit-boost-cli, commit-boost-pbs, commit-boost-signer]

- x86_64-unknown-linux-gnu
- x86_64-pc-windows-gnu
# - x86_64-apple-darwin
- aarch64-apple-darwin
name:
- commit-boost-cli
- commit-boost-pbs
- commit-boost-signer
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
- target: x86_64-apple-darwin
os: macos-latest
# - target: x86_64-apple-darwin
# os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: "stable"

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo index
uses: actions/cache@v3
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}

- name: Cache Cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-${{ matrix.target }}-${{ matrix.name }}-
${{ runner.os }}-cargo-build-${{ matrix.target }}-
${{ runner.os }}-cargo-build-
- name: Install GNU toolchain (Windows)
if: matrix.target == 'x86_64-pc-windows-gnu'
uses: msys2/setup-msys2@v2
Expand All @@ -56,10 +77,7 @@ jobs:
target: ${{ matrix.target }}

- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }} --bin ${{ matrix.name }}
run: cargo build --release --target ${{ matrix.target }} --bin ${{ matrix.name }}
env:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: gcc

Expand All @@ -73,18 +91,16 @@ jobs:
- name: Package binary (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip ${{ matrix.name }}.exe
move ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip ../../../
7z a ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.zip target\${{ matrix.target }}\release\${{ matrix.name }}.exe
- name: Upload binary to release
uses: softprops/action-gh-release@v2
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
files: ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.gz' }}
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}
path: |
${{ matrix.name }}-${{ github.ref_name }}-${{ matrix.target }}.${{ runner.os == 'Windows' && 'zip' || 'tar.gz' }}
build-and-push-docker:
build-and-push-pbs-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -105,17 +121,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push PBS Docker image
uses: docker/build-push-action@v6
with:
Expand All @@ -125,10 +130,31 @@ jobs:
tags: |
ghcr.io/commit-boost/pbs:${{ github.ref_name }}
ghcr.io/commit-boost/pbs:latest
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=ghcr.io/commit-boost/pbs:buildcache
cache-to: type=registry,ref=ghcr.io/commit-boost/pbs:buildcache,mode=max
file: docker/pbs.Dockerfile

build-and-push-signer-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: "stable"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Signer Docker image
uses: docker/build-push-action@v6
with:
Expand All @@ -138,18 +164,29 @@ jobs:
tags: |
ghcr.io/commit-boost/signer:${{ github.ref_name }}
ghcr.io/commit-boost/signer:latest
cache-from: type=gha
cache-to: type=gha,mode=max
file: docker/pbs.Dockerfile
cache-from: type=registry,ref=ghcr.io/commit-boost/signer:buildcache
cache-to: type=registry,ref=ghcr.io/commit-boost/signer:buildcache,mode=max
file: docker/signer.Dockerfile

finalize-release:
needs: [build-binaries, build-and-push-docker]
needs:
- build-binaries
- build-and-push-pbs-docker
- build-and-push-signer-docker
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts

- name: Finalize Release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: ./artifacts/**/*
draft: true
prerelease: false
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

Expand Down
Loading

0 comments on commit d511c26

Please sign in to comment.