Skip to content

Commit 1ef79fb

Browse files
committed
Mintlayer release GitHub action
1 parent 397155e commit 1ef79fb

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: "Release Mintlayer firmware"
2+
3+
on:
4+
push:
5+
tags:
6+
- 'mintlayer-v*'
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
model:
13+
- {id: T2T1, name: "Model T", filename: model_t}
14+
- {id: T2B1, name: "Safe 3 rev. A", filename: safe3_rev_a}
15+
- {id: T3B1, name: "Safe 3 rev. B", filename: safe3_rev_b}
16+
- {id: T3T1, name: "Safe 5", filename: safe5}
17+
name: Build for ${{ matrix.model.name }}
18+
runs-on: ubuntu-latest
19+
env:
20+
# Note: by default, build-docker.sh sets PRODUCTION to 1, which produces firmware with "Trezor"
21+
# as the vendor and without a signature (which will make it unusable).
22+
# Set it to 0 to get one with the "UNSAFE, DO NOT USE!" vendor and with the "DEVEL" signature.
23+
PRODUCTION: 0
24+
steps:
25+
# Note: no need to recurse into submodules here.
26+
- uses: actions/checkout@v4
27+
28+
- name: Build
29+
run: bash build-docker.sh --models ${{ matrix.model.id }} --skip-bitcoinonly --targets firmware ${{ github.ref_name }}
30+
31+
- name: Prepare artifacts
32+
run: |
33+
mkdir artifacts
34+
mv build/core-${{ matrix.model.id }}/firmware/firmware.bin artifacts/${{ matrix.model.filename }}.bin
35+
echo ${{ matrix.model.name }} > artifacts/${{ matrix.model.filename }}_model_name.txt
36+
37+
- name: Upload artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: ${{ matrix.model.filename }}_artifacts
41+
path: artifacts/*
42+
43+
create-release:
44+
name: Create Release
45+
needs: [build]
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Extract version from tag
49+
id: get_version
50+
run: |
51+
VERSION=${GITHUB_REF#refs/tags/mintlayer-v}
52+
echo "Version extracted: $VERSION"
53+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
54+
55+
- name: Download Artifacts
56+
uses: actions/download-artifact@v4
57+
with:
58+
path: artifacts
59+
merge-multiple: true
60+
61+
- name: Generate Release Body
62+
id: generate_body
63+
run: |
64+
echo "BODY<<EOF" >> $GITHUB_OUTPUT
65+
echo "Release version ${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT
66+
echo "" >> $GITHUB_OUTPUT
67+
68+
echo "Available files:" >> $GITHUB_OUTPUT
69+
echo "|Model name|Firmware file|" >> $GITHUB_OUTPUT
70+
echo "|---|---|" >> $GITHUB_OUTPUT
71+
72+
mkdir renamed_artifacts
73+
74+
for bin_file in artifacts/*.bin; do
75+
model_name=$(cat "${bin_file%.bin}_model_name.txt")
76+
77+
new_bin_file_name=mintlayer_trezor_firmware_${{ steps.get_version.outputs.VERSION }}_$(basename "$bin_file")
78+
mv "$bin_file" renamed_artifacts/$new_bin_file_name
79+
80+
echo "|$model_name|$new_bin_file_name|" >> $GITHUB_OUTPUT
81+
done
82+
83+
echo "EOF" >> $GITHUB_OUTPUT
84+
85+
- name: Create Release
86+
uses: ncipollo/release-action@v1
87+
with:
88+
allowUpdates: true
89+
artifacts: "renamed_artifacts/*"
90+
artifactErrorsFailBuild: true
91+
name: "Release ${{ steps.get_version.outputs.VERSION }}"
92+
body: ${{ steps.generate_body.outputs.BODY }}

0 commit comments

Comments
 (0)