Skip to content

Commit

Permalink
feat: add binary checksum generation to build workflow
Browse files Browse the repository at this point in the history
- Add checksum generation step for stratus binary
- Generate checksums.txt file with SHA256 hash
- Upload checksums file as a separate artifact with commit SHA
- Keep checksum file in project root for easy access
  • Loading branch information
pedro-pelicioni-cw authored Feb 17, 2025
1 parent 4d63122 commit 57e2192
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build-binary.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
name: Build Binary

on:
workflow_dispatch:
inputs:
features:
description: "List of features to enable"
required: false
default: ""
push:
branches:
- "main"
paths:
- "src/**"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- "tests/fixtures/**"
- "static/**"
- ".sqlx/**"

env:
RETENTION_DAYS: 90

jobs:
build_binaries:
name: Build and upload
runs-on: ubuntu-22.04
timeout-minutes: 45

concurrency:
group: ${{ github.workflow }}-{{ github.run_id }}
cancel-in-progress: true

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.84

- name: Rust Cache
uses: Swatinem/rust-cache@v2
id: cache-cargo
with:
prefix-key: ${{ runner.os }}-v3-cargo
shared-key: artifact
cache-provider: "github"
save-if: ${{ github.ref_name == 'main' && github.event_name == 'push' }}

- name: Install protoc
run: sudo apt-get install -y protobuf-compiler

- name: Install libsasl2-dev libssl-dev
run: sudo apt-get update && sudo apt install -y build-essential pkg-config libssl-dev libsasl2-dev

name: Build Binary

on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -65,6 +121,11 @@ jobs:
NO_COLOR: 1
FEATURES: "${{ github.event.inputs.features || 'default' }}"

- name: Generate checksums
run: |
cd target/release
sha256sum stratus > ../../checksums.txt
- name: Upload stratus
uses: actions/upload-artifact@v4
id: upload-str
Expand All @@ -74,6 +135,14 @@ jobs:
if-no-files-found: error
retention-days: ${{ env.RETENTION_DAYS }}

- name: Upload checksums
uses: actions/upload-artifact@v4
with:
name: checksums-${{ github.sha }}
path: checksums.txt
if-no-files-found: error
retention-days: ${{ env.RETENTION_DAYS }}

- name: Print outputs
run: |
echo "Artifact ID: ${{ steps.upload-str.outputs.artifact-id }} (stratus)"
Expand Down

0 comments on commit 57e2192

Please sign in to comment.