From c5ec148001eba94300c4868038e851cae4c45485 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 17 May 2025 08:04:48 +0300 Subject: [PATCH] ci: set up build and release workflows --- .github/workflows/build.yml | 53 +++++++++++++ .github/workflows/release.yml | 99 +++++++++++++++++++++++++ .github/{workflow => workflows}/tag.yml | 0 3 files changed, 152 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml rename .github/{workflow => workflows}/tag.yml (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..853f830 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build & Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Run tests + run: cargo test + + build: + name: Build + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + # TODO: eventually we'd like to gate certain features + # behind target OS, at which point this may be usable. + #- os: macos-latest + # target: x86_64-apple-darwin + #- os: windows-latest + # target: x86_64-pc-windows-msvc + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build + run: cargo build --release --target ${{ matrix.target }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a5cc12f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +name: Publish Release Builds + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + create-release: + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + release_id: ${{ steps.create_release.outputs.id }} + steps: + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + draft: false + prerelease: false + generate_release_notes: true + + build-release: + needs: create-release + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + name: superfreq-linux-amd64 + cross: false + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + name: superfreq-linux-arm64 + cross: true + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Setup cross-compilation (Linux ARM64) + if: matrix.cross && matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Install cross + if: matrix.cross + uses: taiki-e/install-action@v2 + with: + tool: cross + + - name: Build binary (native) + if: ${{ !matrix.cross }} + run: cargo build --release --target ${{ matrix.target }} + + - name: Build binary (cross) + if: ${{ matrix.cross }} + run: cross build --release --target ${{ matrix.target }} + + - name: Upload Release Asset + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.name }} + + generate-checksums: + needs: [create-release, build-release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Download Assets + uses: robinraju/release-downloader@v1 + with: + tag: ${{ github.ref_name }} + fileName: "superfreq-*" + out-file-path: "." + + - name: Generate checksums + run: | + sha256sum superfreq-* > SHA256SUMS + + - name: Upload Checksums + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: SHA256SUMS + diff --git a/.github/workflow/tag.yml b/.github/workflows/tag.yml similarity index 100% rename from .github/workflow/tag.yml rename to .github/workflows/tag.yml