Skip to content

Commit 54bf3b4

Browse files
committed
chore: Update gh actions workflows
1 parent 5ec4208 commit 54bf3b4

File tree

7 files changed

+100
-21
lines changed

7 files changed

+100
-21
lines changed

.github/workflows/auto-tag-versions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ jobs:
2222
VERSION=$(cat version.txt | grep firmware | cut -f 2-2 -d '=' | awk -F ':' '{ print 0+$1 "." 0+$2 "." $3*2**8 + $4 }')
2323
echo $VERSION
2424
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}/git/refs -d '{"ref":"refs/tags/v'${VERSION}'","sha":"'${COMMIT}'"}'
25+
echo "Tag v${VERSION} created successfully."

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ jobs:
1515
matrix:
1616
firmware: [Main]
1717
target: [Release]
18+
coin_support: ["BTC_ONLY", "MULTI_COIN"]
1819
uses: ./.github/workflows/containerized-build.yml
1920
with:
2021
firmware: ${{ matrix.firmware }}
2122
target: ${{ matrix.target }}
23+
coin_support_variant: ${{ matrix.coin_support }}
2224
secrets: inherit
2325
create-release:
2426
needs: build-firmwares
@@ -49,4 +51,4 @@ jobs:
4951
run: |
5052
content_type=$(file -b --mime-type Main-Release-outputs/Cypherock-Main.bin)
5153
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
52-
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
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

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,4 @@ jobs:
198198
cat test_results.txt
199199
# Unity prints "OK" if all tests pass, "FAIL" if tests fail; return 1 to indicate failure
200200
if [ ! "$(tail -n 1 test_results.txt)" = "OK" ]; then exit 1; fi
201+

.github/workflows/containerized-build.yml

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,81 @@ on:
99
target:
1010
required: true
1111
type: string
12+
coin_support_variant:
13+
required: true
14+
type: string
15+
workflow_dispatch:
16+
inputs:
17+
firmware:
18+
required: true
19+
type: string
20+
default: 'Main'
21+
target:
22+
required: true
23+
type: string
24+
default: 'Release'
25+
coin_support_variant:
26+
required: true
27+
type: string
28+
default: 'MULTI_COIN'
1229

1330
jobs:
1431
build:
1532
runs-on: ubuntu-latest
1633
container:
1734
image: cypherock/x1-firmware-builder:v0.0.0
35+
1836
steps:
19-
- name: Build Firmware (${{ inputs.firmware }} - ${{ inputs.target }})
37+
- name: Set VERSION_TAG
38+
id: set_version_tag
2039
run: |
2140
if [[ "${{ github.ref_type }}" == "tag" ]]; then
22-
export VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/')
41+
echo "VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/')" >> $GITHUB_OUTPUT
2342
elif [[ "${{ github.ref_type }}" == "branch" ]]; then
24-
export VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/')
43+
echo "VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/')" >> $GITHUB_OUTPUT
2544
else
26-
# reftype is repository; use default branch
27-
export VERSION_TAG=main
45+
echo "VERSION_TAG=main" >> $GITHUB_OUTPUT
2846
fi
29-
git clone --branch ${VERSION_TAG} --depth 1 https://github.com/${{ github.repository }}.git --recurse-submodules
30-
mkdir build && cd x1_wallet_firmware && mkdir build && cd build
31-
cmake -DCMAKE_BUILD_TYPE="${{ inputs.target }}" -DFIRMWARE_TYPE="${{ inputs.firmware }}" -DCMAKE_BUILD_PLATFORM="Device" -G "Ninja" ..
32-
ninja && cd ../..
33-
cp x1_wallet_firmware/build/Cypherock-*.* ./build/
34-
- name: Archive Build Artifacts
47+
48+
- name: Checkout Repository
49+
uses: actions/checkout@v4
50+
with:
51+
ref: ${{ steps.set_version_tag.outputs.VERSION_TAG }}
52+
submodules: recursive
53+
54+
- name: Build Firmware (${{ inputs.firmware }} - ${{ inputs.target }} - ${{ inputs.coin_support_variant }})
55+
run: |
56+
cd x1_wallet_firmware
57+
58+
BTC_ONLY_FLAG="OFF"
59+
if [[ "${{ inputs.coin_support_variant }}" == "BTC_ONLY" ]]; then
60+
BTC_ONLY_FLAG="ON"
61+
fi
62+
63+
BUILD_DIR="build_${{ inputs.coin_support_variant }}"
64+
mkdir -p "${BUILD_DIR}"
65+
66+
cmake -B "${BUILD_DIR}" \
67+
-DDEV_SWITCH=OFF \
68+
-DUNIT_TESTS_SWITCH:BOOL=OFF \
69+
-DBTC_ONLY:BOOL="${BTC_ONLY_FLAG}" \
70+
-DSIGN_BINARY=OFF \
71+
-DCMAKE_BUILD_TYPE:STRING="${{ inputs.target }}" \
72+
-DFIRMWARE_TYPE="${{ inputs.firmware }}" \
73+
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF \
74+
-DCMAKE_BUILD_PLATFORM:STRING="Device" \
75+
-G "Ninja" .
76+
77+
ninja -C "${BUILD_DIR}"
78+
79+
cd ..
80+
81+
mkdir -p build
82+
83+
cp x1_wallet_firmware/"${BUILD_DIR}"/Cypherock-*.* ./build/
84+
85+
- name: Archive Build Artifacts (${{ inputs.coin_support_variant }})
3586
uses: actions/upload-artifact@v4
3687
with:
37-
name: ${{ inputs.firmware }}-${{ inputs.target }}-outputs
38-
path: build
88+
name: ${{ inputs.firmware }}-${{ inputs.target }}-${{ inputs.coin_support_variant }}-outputs
89+
path: build

.github/workflows/publish-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
2727
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
2828
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29-
run: aws s3 cp ./doxygen/html s3://docs-x1.cypherock.com --recursive
29+
run: aws s3 cp ./doxygen/html s3://docs-x1.cypherock.com --recursive

.github/workflows/version-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
version0=$(git show ${SHA_BASE}:version.txt | grep firmware | cut -f 2-2 -d '=' | awk -F ':' '{ print $1*2**24 + $2*2**16 + $3*2**8 + $4 }')
2525
version1=$(git show ${SHA_HEAD}:version.txt | grep firmware | cut -f 2-2 -d '=' | awk -F ':' '{ print $1*2**24 + $2*2**16 + $3*2**8 + $4 }')
2626
echo $version0:$version1
27-
if [[ $version0 > $version1 ]]; then echo -e "Version downgrade detected\nfrom $version0 to $version1\n"; exit 1; fi
27+
if [[ $version0 > $version1 ]]; then echo -e "Version downgrade detected\nfrom $version0 to $version1\n"; exit 1; fi

utilities/build.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,58 @@
11
#!/usr/bin/env bash
22

3+
# Function to display usage information
34
usage() {
4-
echo -e "USAGE: $0 [-c] [-u] [-f <main|initial>] [-p <device|simulator>] [-t <dev|debug|release|unit_tests>]"
5+
echo -e "USAGE: $0 [-c] [-u] [-b] [-f <main|initial>] [-p <device|simulator>] [-t <dev|debug|release|unit_tests>]"
56
echo -e "Parameters are optional and assumes 'main debug device' if not provided"
67
echo -e "\n\n -c \t Performs a forced clean before invoking build"
78
echo -e "\n\n -u \t Generate unsigned binary"
9+
echo -e "\n\n -b \t Build BTC-only firmware"
810
echo -e "\n\n -f \t Sets the preferred firmware to build. Can be main or initial"
911
echo -e "\n\n -p \t Provides the preferred platform to build for. Can be simulator or device"
1012
echo -e "\n\n -t \t Tells the build type that should be generate. Can be a valid build type."
1113
echo -e "\t \t For example release, debug, dev, unit_tests"
1214
exit 1
1315
}
1416

17+
# Function to validate the firmware name
1518
validate_name() {
1619
if ! [[ "$ACTIVE_TYPE" =~ ^(Main|Initial)$ ]]; then
1720
echo -e "Incorrect firmware ($ACTIVE_TYPE) selected for build\n"
1821
usage
1922
fi
2023
}
2124

25+
# Function to validate the build platform
2226
validate_platform() {
2327
if ! [[ "$BUILD_PLATFORM" =~ ^(Device|Simulator)$ ]]; then
2428
echo -e "Incorrect platform ($BUILD_PLATFORM) selected for build\n"
2529
usage
2630
fi
2731
}
2832

33+
# Function to validate the build type
2934
validate_type() {
3035
if ! [[ "$BUILD_TYPE" =~ ^(Debug|Release|Dev|Unit_tests)$ ]]; then
3136
echo -e "Incorrect type ($BUILD_TYPE) selected for build\n"
3237
usage
3338
fi
3439
}
3540

41+
# --- Script Defaults ---
3642
ACTIVE_ROOT_DIR=$(pwd)
3743
ACTIVE_TYPE=Main
3844
BUILD_TYPE=Debug
3945
BUILD_PLATFORM=Device
4046
UNIT_TESTS=OFF
4147
DEV=OFF
4248
SIGN_BINARY=ON
49+
BTC_ONLY=OFF # Default to multi-coin build
4350

44-
while getopts 'cf:p:t:u' flag; do
51+
# --- Parse Command Line Arguments ---
52+
while getopts 'cbuf:p:t:' flag; do
4553
case "${flag}" in
4654
c) clean_flag="true" ;;
55+
b) BTC_ONLY=ON ;;
4756
f) ACTIVE_TYPE=$(echo "${OPTARG}" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}') ;;
4857
p) BUILD_PLATFORM=$(echo "${OPTARG}" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}') ;;
4958
t) BUILD_TYPE=$(echo "${OPTARG}" | awk '{print toupper(substr($0, 1, 1)) tolower(substr($0, 2))}') ;;
@@ -52,6 +61,7 @@ while getopts 'cf:p:t:u' flag; do
5261
esac
5362
done
5463

64+
# --- Validate Inputs ---
5565
shift "$((OPTIND - 1))"
5666
validate_name
5767
validate_platform
@@ -61,6 +71,7 @@ if [ $# -gt 0 ]; then
6171
usage
6272
fi
6373

74+
# --- Set Build-specific Variables ---
6475
case $BUILD_TYPE in
6576
Dev)
6677
DEV=ON
@@ -74,17 +85,26 @@ Unit_tests)
7485
;;
7586
esac
7687

88+
# --- Prepare Build Directory ---
89+
BUILD_DIR_SUFFIX=""
90+
if [ "${BTC_ONLY}" = "ON" ]; then
91+
BUILD_DIR_SUFFIX="_BTC"
92+
fi
93+
94+
BUILD_DIR="build/${ACTIVE_TYPE}${BUILD_DIR_SUFFIX}"
95+
7796
cd "${ACTIVE_ROOT_DIR}" || exit
78-
mkdir -p "build/${ACTIVE_TYPE}"
79-
cd "build/${ACTIVE_TYPE}" || exit
97+
mkdir -p "${BUILD_DIR}"
98+
cd "${BUILD_DIR}" || exit
8099

81-
# remove previous cmake configuration to ensure we are building with
100+
# Remove previous cmake configuration to ensure we are building with
82101
# currently requested build configuration; it is important to delete
83102
# the existing cmake configuration
84103
if [ -f "CMakeCache.txt" ]; then
85104
rm "CMakeCache.txt"
86105
fi
87106

107+
# --- Find Build Tools ---
88108
# Detect if any one (cmake or mingw32-cmake) exists
89109
CMAKE=$(which cmake)
90110
if [ "${CMAKE}" = "" ]; then
@@ -115,12 +135,15 @@ if [ "${BUILD_TOOL}" = "" ]; then
115135
exit 1
116136
fi
117137

138+
# --- Run Build ---
118139
if [[ "${clean_flag}" = "true" ]]; then
119140
rm -rf "${ACTIVE_ROOT_DIR}/generated/proto"
120141
fi
121142

143+
# Configure the project with CMake
122144
"${CMAKE}" -DDEV_SWITCH=${DEV} \
123145
-DUNIT_TESTS_SWITCH:BOOL="${UNIT_TESTS}" \
146+
-DBTC_ONLY:BOOL="${BTC_ONLY}" \
124147
-DSIGN_BINARY:BOOL="${SIGN_BINARY}" \
125148
-DCMAKE_BUILD_TYPE:STRING="${BUILD_TYPE}" \
126149
-DFIRMWARE_TYPE="${ACTIVE_TYPE}" \
@@ -131,6 +154,7 @@ fi
131154
# exit if configuration failed with errors
132155
if [ ! $? -eq 0 ]; then exit 1; fi
133156

157+
# Clean and build the project
134158
if [[ "${clean_flag}" = "true" ]]; then
135159
"${BUILD_TOOL}" clean
136160
fi

0 commit comments

Comments
 (0)