name: release
on:
push:
tags:
- "v*.*.*"
jobs:
build:
strategy:
matrix:
config:
[
{ os: ubuntu-22.04, target: x86_64-unknown-linux-gnu },
{
os: ubuntu-22.04-arm,
target: aarch64-unknown-linux-gnu,
},
]
runs-on: ${{ matrix.config.os }}
env:
TARGET: "${{ matrix.config.target }}"
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa - uses: DeterminateSystems/flakehub-cache-action@83282a8aef353db1d659d3bacf4a28b6683de0b3 - name: Show nix version
run: nix --version
- name: Set up nix dev env
run: nix develop --command echo 0
- name: Run `cargo test`
run: nix develop --command cargo test --workspace
- name: Run `cargo hack`
run: nix develop --command just hack
- name: Build container image
run: nix build .#container
- name: Upload container image to GitHub's container registry
run: |
export CONTAINERS_REGISTRIES_CONF=/dev/null
nix develop --ignore-environment --keep-env-var CONTAINERS_REGISTRIES_CONF --command skopeo copy --dest-creds="${{ github.repository_owner }}:${{ github.token }}" docker-archive:./result docker://ghcr.io/javierhonduco/lightswitch:${{ github.ref_name }}
nix develop --ignore-environment --keep-env-var CONTAINERS_REGISTRIES_CONF --command skopeo copy --dest-creds="${{ github.repository_owner }}:${{ github.token }}" docker-archive:./result docker://ghcr.io/javierhonduco/lightswitch:latest
- name: Upload container
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: lightswitch-container-${{ matrix.config.target }}
path: ./result
- name: Build `lightswitch` statically linked with glibc
run: nix develop --ignore-environment --keep TARGET --command bash -c 'RUSTFLAGS="-C target-feature=+crt-static" cargo build --release --target $TARGET'
- name: Upload static binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: lightswitch-static-glibc-${{ matrix.config.target }}
path: ./target/${{ matrix.config.target }}/release/lightswitch
release:
runs-on: ubuntu-22.04
needs: [build]
permissions:
contents: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c - name: Display artifacts structure
run: tree -h
- name: Rename artifacts
run: |
mkdir renamed
cp lightswitch-container-x86_64-unknown-linux-gnu/result renamed/lightswitch-container-x86_64-unknown-linux-gnu
cp lightswitch-static-glibc-x86_64-unknown-linux-gnu/lightswitch renamed/lightswitch-static-glibc-x86_64-unknown-linux-gnu
cp lightswitch-container-aarch64-unknown-linux-gnu/result renamed/lightswitch-container-aarch64-unknown-linux-gnu
cp lightswitch-static-glibc-aarch64-unknown-linux-gnu/lightswitch renamed/lightswitch-static-glibc-aarch64-unknown-linux-gnu
- name: Create release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 with:
files: |
renamed/lightswitch-container-x86_64-unknown-linux-gnu
renamed/lightswitch-static-glibc-x86_64-unknown-linux-gnu
renamed/lightswitch-container-aarch64-unknown-linux-gnu
renamed/lightswitch-static-glibc-aarch64-unknown-linux-gnu
publish:
runs-on: ubuntu-22.04
needs: [build]
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa - uses: DeterminateSystems/flakehub-cache-action@83282a8aef353db1d659d3bacf4a28b6683de0b3 - name: Show nix version
run: nix --version
- name: Set up nix dev env
run: nix develop --command echo 0
- name: Publish workspace dependencies
run: nix develop --command cargo publish --workspace --exclude lightswitch
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish main crate
run: nix develop --command cargo publish --package lightswitch
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}