@@ -15,40 +15,98 @@ jobs:
15
15
matrix :
16
16
firmware : [Main]
17
17
target : [Release]
18
- coin_support : ["BTC_ONLY", "MULTI_COIN"]
18
+ coin_support : ["BTC_ONLY", "MULTI_COIN"] # Builds both BTC_ONLY and MULTI_COIN variants
19
19
uses : ./.github/workflows/containerized-build.yml
20
20
with :
21
21
firmware : ${{ matrix.firmware }}
22
22
target : ${{ matrix.target }}
23
23
coin_support_variant : ${{ matrix.coin_support }}
24
24
secrets : inherit
25
+
25
26
create-release :
26
- needs : build-firmwares
27
+ needs : build-firmwares # Depends on all firmwares being built
27
28
runs-on : ubuntu-latest
28
29
if : ${{ github.ref_type }} == 'tag'
29
30
steps :
30
31
- name : Checkout
31
32
uses : actions/checkout@v3
33
+
32
34
- name : Download artifacts
33
35
uses : actions/download-artifact@v4
34
36
with :
35
- path : ./
37
+ path : ./ # Downloads all artifacts to the current directory
38
+
36
39
- name : Publish a release
37
40
env :
38
41
TAG_NAME : ${{ github.ref_name }}
39
42
auth_token : ${{ secrets.GITHUB_TOKEN }}
40
43
REPOSITORY : ${{ github.repository }}
41
44
run : |
42
- chkmain=$(sha256sum Main-Release-outputs/Cypherock-Main.bin | cut -f -1 -d ' ')
45
+ # Calculate SHA256 hash for the MULTI_COIN firmware
46
+ # The path assumes download-artifact placed it in Main-Release-MULTI_COIN-outputs/build/
47
+ chkmain_multicoin=$(sha256sum Main-Release-MULTI_COIN-outputs/build/Cypherock-Main.bin | cut -f -1 -d ' ')
48
+
49
+ # Calculate SHA256 hash for the BTC_ONLY firmware
50
+ # The path assumes download-artifact placed it in Main-Release-BTC_ONLY-outputs/build/
51
+ # The filename is Cypherock-Main-btc.bin due to the CMakeLists.txt modification
52
+ chkmain_btc_only=$(sha256sum Main-Release-BTC_ONLY-outputs/build/Cypherock-Main-btc.bin | cut -f -1 -d ' ')
53
+
43
54
APP_VERSION=$(cat version.txt | grep firmware | cut -f 2-2 -d '=' | awk -F ':' '{ print 0+$1 "." 0+$2 "." $3*2**8 + $4 }')
44
55
HW_VERSION=$(cat version.txt | grep hardware | cut -f 2-2 -d '=' | awk -F ':' '{ print 0+$1 "." 0+$2 "." $3*2**8 + $4 }')
45
- echo ${APP_VERSION}:${HW_VERSION}
46
- curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${auth_token}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/${REPOSITORY}/releases -d '{"tag_name":"'${TAG_NAME}'","target_commitish":"main","name":"'${TAG_NAME}'","body":"Application version: '${APP_VERSION}'\r\nHardware version: '${HW_VERSION}'\r\n## SHA256 of binaries:\r\n**Cypherock-Main.bin** : '${chkmain}'","draft":true,"prerelease":false,"generate_release_notes":true}' > output.txt
56
+
57
+ echo "Application version: ${APP_VERSION}"
58
+ echo "Hardware version: ${HW_VERSION}"
59
+
60
+ # Create the release with both firmware hashes in the body
61
+ curl -X POST \
62
+ -H "Accept: application/vnd.github+json" \
63
+ -H "Authorization: Bearer ${auth_token}" \
64
+ -H "X-GitHub-Api-Version: 2022-11-28" \
65
+ https://api.github.com/repos/${REPOSITORY}/releases \
66
+ -d '{
67
+ "tag_name":"'${TAG_NAME}'",
68
+ "target_commitish":"main",
69
+ "name":"'${TAG_NAME}'",
70
+ "body":"Application version: '${APP_VERSION}'\r\nHardware version: '${HW_VERSION}'\r\n## SHA256 of binaries:\r\n**Cypherock-Main.bin** : '${chkmain_multicoin}' \r\n**Cypherock-Main-btc.bin** : '${chkmain_btc_only}'",
71
+ "draft":true,
72
+ "prerelease":false,
73
+ "generate_release_notes":true
74
+ }' > output.txt
75
+
76
+ # Extract upload_url for subsequent asset uploads
47
77
echo "upload_url=$(cat output.txt | grep "\"upload_url\":" | cut -f 4-4 -d '"' | cut -f 1-1 -d '{')" >> $GITHUB_ENV
78
+
48
79
- name : Upload assets
49
80
env :
50
81
auth_token : ${{ secrets.GITHUB_TOKEN }}
82
+ upload_url : ${{ env.upload_url }} # Use the extracted upload_url
51
83
run : |
52
- content_type=$(file -b --mime-type Main-Release-outputs/Cypherock-Main.bin)
53
- curl -X POST -H "Content-Type: ${content_type}" -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${auth_token}" -H "X-GitHub-Api-Version: 2022-11-28" ${upload_url}?name=Cypherock-Main.bin --data-binary @Main-Release-outputs/Cypherock-Main.bin
54
- curl -X POST -H "Content-Type: ${content_type}" -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${auth_token}" -H "X-GitHub-Api-Version: 2022-11-28" ${upload_url}?name=version.txt --data-binary @version.txt
84
+ # Upload the MULTI_COIN firmware binary
85
+ content_type_multicoin=$(file -b --mime-type Main-Release-MULTI_COIN-outputs/build/Cypherock-Main.bin)
86
+ curl -X POST \
87
+ -H "Content-Type: ${content_type_multicoin}" \
88
+ -H "Accept: application/vnd.github+json" \
89
+ -H "Authorization: Bearer ${auth_token}" \
90
+ -H "X-GitHub-Api-Version: 2022-11-28" \
91
+ "${upload_url}?name=Cypherock-Main.bin" \
92
+ --data-binary @Main-Release-MULTI_COIN-outputs/build/Cypherock-Main.bin
93
+
94
+ # Upload the BTC_ONLY firmware binary
95
+ content_type_btc_only=$(file -b --mime-type Main-Release-BTC_ONLY-outputs/build/Cypherock-Main-btc.bin)
96
+ curl -X POST \
97
+ -H "Content-Type: ${content_type_btc_only}" \
98
+ -H "Accept: application/vnd.github+json" \
99
+ -H "Authorization: Bearer ${auth_token}" \
100
+ -H "X-GitHub-Api-Version: 2022-11-28" \
101
+ "${upload_url}?name=Cypherock-Main-btc.bin" \
102
+ --data-binary @Main-Release-BTC_ONLY-outputs/build/Cypherock-Main-btc.bin
103
+
104
+ # Upload version.txt
105
+ content_type_version=$(file -b --mime-type version.txt)
106
+ curl -X POST \
107
+ -H "Content-Type: ${content_type_version}" \
108
+ -H "Accept: application/vnd.github+json" \
109
+ -H "Authorization: Bearer ${auth_token}" \
110
+ -H "X-GitHub-Api-Version: 2022-11-28" \
111
+ "${upload_url}?name=version.txt" \
112
+ --data-binary @version.txt
0 commit comments