Skip to content

Merge pull request #417 from BlueSCSI/eric/fw-update-checks #452

Merge pull request #417 from BlueSCSI/eric/fw-update-checks

Merge pull request #417 from BlueSCSI/eric/fw-update-checks #452

name: Build BlueSCSI firmware
on:
push:
branches: [main]
tags: ['*']
pull_request:
workflow_dispatch:
jobs:
build_firmware:
name: Build firmware on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Check out code from GitHub
uses: actions/checkout@v6
with:
path: BlueSCSI
fetch-depth: "0"
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Cache Nix store
uses: cachix/cachix-action@v17
with:
name: bluescsi
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
continue-on-error: true
- name: Build firmware
run: |
cd BlueSCSI
nix develop --command ./build.sh
- name: Generate size report
if: github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
run: |
cd BlueSCSI
nix develop --command python3 utils/compare_elf.py --from-release build/ --markdown -o size-report.md
# Pull requests from forks only get a read-only GITHUB_TOKEN, so this job
# cannot post the comment itself. size_comment.yml picks the report up.
- name: Upload size report
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v7
with:
name: size-report
path: BlueSCSI/size-report.md
if-no-files-found: error
- name: Rename firmware files
run: |
cd BlueSCSI
utils/make_dist.sh
- name: Upload binaries into build artifacts
uses: actions/upload-artifact@v7
with:
path: BlueSCSI/dist/*
name: BlueSCSI binaries
- name: Upload to latest release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref == 'refs/heads/main' && github.repository == 'BlueSCSI/BlueSCSI-v2' }}
run: |
cd BlueSCSI
git tag -d latest
git tag latest
git push origin --force latest
cd dist
gh api repos/${GITHUB_REPOSITORY}/releases/tags/latest | jq -r '.assets[] | [.url] | @tsv' | xargs -n 1 gh api -X DELETE || true
gh release upload --repo ${GITHUB_REPOSITORY} --clobber latest *
- name: Upload to newly created release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository == 'BlueSCSI/BlueSCSI-v2' }}
run: |
set +e
RELEASE=$(basename ${{github.ref}})
if [[ "$RELEASE" =~ ^v[0-9]{4}\.[0-9]{2}\.[0-9]{2}$ ]]; then
RELEASE_FLAGS="--latest"
else
RELEASE_FLAGS="--prerelease"
fi
gh release create --repo ${GITHUB_REPOSITORY} --draft -t "$RELEASE" $RELEASE_FLAGS "$RELEASE" BlueSCSI/dist/*
status=$?
set -e
if [ $status -ne 0 ]; then
gh release upload --repo ${GITHUB_REPOSITORY} --clobber "$RELEASE" BlueSCSI/dist/*
fi