-
Notifications
You must be signed in to change notification settings - Fork 65
99 lines (87 loc) · 3.06 KB
/
Copy pathfirmware_build.yml
File metadata and controls
99 lines (87 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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