Skip to content

Rust builds

Rust builds #40

Workflow file for this run

name: Rust builds
on:
push:
branches: [main]
tags:
- v*
pull_request:
branches: [main]
permissions:
contents: write
id-token: write
attestations: write
actions: read
jobs:
create-release:
needs:
- build
- nixbuild
- create-sbom
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Rename and move artifacts
run: |
mv artifacts/sbom.spdx.json sbom.spdx.json
- uses: actions/attest-sbom@v1
with:
subject-path: artifacts/*
subject-name: "counter@${{ github.ref_name }}"
sbom-path: "sbom.spdx.json"
push-to-registry: false
- name: release
uses: ncipollo/release-action@v1
id: create_release
with:
generateReleaseNotes: true
artifacts: "artifacts/*"
nixbuild:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-23.05
- uses: DeterminateSystems/magic-nix-cache-action@v3
- run: nix-build
- run: nix-shell --run "echo OK"
create-sbom:
runs-on: ubuntu-latest
steps:
- uses: anchore/sbom-action@v0
with:
artifact-name: "sbom.spdx.json"
output-file: "sbom.spdx.json"
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [stable]
target: [x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc, i686-pc-windows-msvc, x86_64-apple-darwin, aarch64-apple-darwin] #x86_64-unknown-linux-musl,
package: ["counter"]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: linux_64-bit
#- os: ubuntu-latest
# target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
name: windows_64-bit
- os: windows-latest
target: i686-pc-windows-msvc
name: windows_32-bit
- os: macos-latest
target: x86_64-apple-darwin
name: macos_64-bit
- os: macos-latest
target: aarch64-apple-darwin
name: macos_aarch64
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: moonrepo/setup-rust@v1
with:
cache-target: release
targets: ${{ matrix.target }}
- name: Linux Specific libs install
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: librust-atk-dev libglib2.0-dev libgtk-3-dev
execute_install_scripts: true
- name: Configure sccache env var and set build profile to ephemeral build
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Run build
run: cargo build --target ${{ matrix.target }} --release --package ${{ matrix.package }} --bin ${{ matrix.package }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}-${{ matrix.name }}"
path: |
target/${{ matrix.target }}/release/${{ matrix.package }}*
!target/${{ matrix.target }}/release/deps
!target/${{ matrix.target }}/release/build
!target/${{ matrix.target }}/release/.fingerprint
!target/${{ matrix.target }}/release/examples
!target/${{ matrix.target }}/release/incremental
!target/${{ matrix.target }}/release/.cargo-lock
!target/${{ matrix.target }}/release/*.d
!target/${{ matrix.target }}/release/*.pdb