Skip to content

Commit

Permalink
Improve binary build workflow for cross-platform releases
Browse files Browse the repository at this point in the history
- Add proper architecture handling in matrix configuration
- Implement caching for Go modules and Rust dependencies
- Streamline dependency installation for both Linux and macOS
- Improve binary artifact handling and checksums
- Add retention policy for build artifacts
- Split build steps for better clarity and maintainability

This update ensures more reliable and efficient binary builds
across all supported platforms.
  • Loading branch information
wojciechos committed Dec 10, 2024
1 parent 926b485 commit 6348e10
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ jobs:
matrix:
include:
- os: ubuntu-latest
arch: amd64
- os: macos-13
arch: amd64
- os: ubuntu-arm64-4-core
arch: arm64
- os: macos-latest
arch: arm64
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -29,46 +33,64 @@ jobs:
with:
fetch-depth: 0

- name: Get latest tag
run: echo "TAG=$(git describe --tags)" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Get artifact name
run: echo "ARTIFACT_NAME=juno-${{ env.TAG }}-${{ runner.os }}-$(uname -m)" >> $GITHUB_ENV
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: |
vm/rust
core/rust
starknet/compiler/rust
- name: Set version info
run: |
echo "TAG=$(git describe --tags)" >> $GITHUB_ENV
echo "ARTIFACT_NAME=juno-${{ env.TAG }}-${{ runner.os }}-${{ matrix.arch }}" >> $GITHUB_ENV
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update -qq && sudo apt-get install -y upx-ucl build-essential cargo git golang libjemalloc-dev libjemalloc2 -y
run: |
sudo apt-get update -qq
sudo apt-get install -y upx-ucl build-essential libjemalloc-dev libjemalloc2 libbz2-dev
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install cargo-c jemalloc

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
run: brew install jemalloc

- name: Build Juno
- name: Build binary
run: make juno

- name: Compress binary (Linux)
if: runner.os == 'Linux'
run: |
make juno
if [[ "${{ runner.os }}" != "macOS" ]]; then
upx build/juno
fi
upx build/juno
mv build/juno ${{ env.ARTIFACT_NAME }}
- name: Generate Checksum
id: checksum
- name: Prepare binary (macOS)
if: runner.os == 'macOS'
run: mv build/juno ${{ env.ARTIFACT_NAME }}

- name: Generate checksum
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
shasum -a 256 ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256
shasum -a 256 ${{ env.ARTIFACT_NAME }}
else
sha256sum ${{ env.ARTIFACT_NAME }} > ${{ env.ARTIFACT_NAME }}.sha256
fi
sha256sum ${{ env.ARTIFACT_NAME }}
fi > ${{ env.ARTIFACT_NAME }}.sha256
- name: Upload Artifact
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
${{ env.ARTIFACT_NAME }}
${{ env.ARTIFACT_NAME }}.sha256
retention-days: 5

0 comments on commit 6348e10

Please sign in to comment.