Skip to content

Commit

Permalink
Add bidirectional binaries to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
LArkema committed Dec 2, 2023
1 parent 9c5f34e commit 271c49b
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 121 deletions.
35 changes: 22 additions & 13 deletions .github/workflows/compile-sketches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ on:

env:
CONFIG_FILE: ./DCTransistor/config.h
BI_CONFIG_FILE: ./DCTransistor-Bidirectional/config.h
BOM_FILE: bom.json
BIN_NAME: dctransistor.bin
BI_BIN_NAME: dctransistor-bidirectional.bin

jobs:
compile-sketches:
Expand All @@ -24,6 +26,7 @@ jobs:
env:
COMPILE_OUT_DIR: /tmp/
COMPILE_OUT_NAME: DCTransistor.ino.bin
COMPILE_OUT_BI_NAME: DCTransistor-Bidirectional.ino.bin


steps:
Expand All @@ -44,6 +47,7 @@ jobs:
let "new_minor_version=code_minor_version+1"
next_version=$(echo -n ${code_version} | awk -F. '{printf("%s.%s", $1, $2)}'; echo -n ".${new_minor_version}")
sed -i -e "/define VERSION /s/${code_version}/${next_version}/" ${CONFIG_FILE}
sed -i -e "/define VERSION /s/${code_version}/${next_version}/" ${BI_CONFIG_FILE}"
else
next_version=$code_version
fi
Expand All @@ -57,6 +61,7 @@ jobs:
- name: Inject API Key
run: |
sed -i -E "/SECRET_WMATA_API_KEY/s/[0-9a-f]{32}/${{ secrets.WMATA_API_KEY }}/" ${CONFIG_FILE}
sed -i -E "/SECRET_WMATA_API_KEY/s/[0-9a-f]{32}/${{ secrets.WMATA_API_KEY }}/" ${BI_CONFIG_FILE}
- name: Install Arduino Cli
uses: arduino/[email protected]
- name: Install boards and libraries
Expand All @@ -69,34 +74,38 @@ jobs:
- name: Compile sketches
run: |
arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 --export-binaries --output-dir ${COMPILE_OUT_DIR} ./DCTransistor/
arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 --export-binaries --output-dir ${COMPILE_OUT_DIR} ./DCTransistor-Bidirectional/
- name: Move and GZip binaries
run: |
mv ${COMPILE_OUT_DIR}${COMPILE_OUT_NAME} ${BIN_NAME}
mv ${COMPILE_OUT_DIR}${COMPILE_OUT_BI_NAME} ${BI_BIN_NAME}
gzip -k -f ${BIN_NAME}
gzip -k -f ${BI_BIN_NAME}
- name: Remove WMATA API Key
run: |
sed -i "s/${{ secrets.WMATA_API_KEY }}/0123456789abcdef0123456789abcdef/" ${CONFIG_FILE}
sed -i "s/${{ secrets.WMATA_API_KEY }}/0123456789abcdef0123456789abcdef/" ${BI_CONFIG_FILE}
- name: Commit changes to repo
run: |
if [[ $(git status) != *"nothing to commit, working tree clean"* ]]; then
git config user.email "<>"
git config user.name "Binary Update Bot"
git add .
git commit -m "Update Binary"
git commit -m "Update Binaries"
git push origin main
else
echo "No updates!"
fi
- name: Upload Binary Artifact
uses: actions/upload-artifact@v3.1.2
- name: Upload Binary Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.BIN_NAME }}
path: ${{ env.BIN_NAME }}
- name: Upload GZIP Artifact
uses: actions/upload-artifact@v3.1.2
name: Binary Artifact Uploads
path: dctransistor*.bin
- name: Upload GZIP Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.BIN_NAME }}.gz
path: ${{ env.BIN_NAME }}.gz
name: GZIP Artifact Uploads
path: dctransistor*.gz


build-release:
Expand All @@ -107,15 +116,15 @@ jobs:
- name: Download Binary Artifact
uses: actions/[email protected]
with:
name: ${{ env.BIN_NAME }}
name: Binary Artifact Uploads
- name: Download GZIP Artifact
uses: actions/[email protected]
with:
name: ${{ env.BIN_NAME }}.gz
name: GZIP Artifact Uploads
- name: create-release
uses: ncipollo/[email protected]
id: create-release
with:
artifacts: "${{ env.BIN_NAME }},${{ env.BIN_NAME}}.gz"
artifacts: "${{ env.BIN_NAME }},${{ env.BIN_NAME }}.gz,${{ env.BI_BIN_NAME }},${{ env.BI_BIN_NAME }}.gz"
tag: ${{ needs.compile-sketches.outputs.release-version }}
body: "Automated pipeline release of dctransistor binary"
body: "Automated pipeline release of dctransistor binaries"
7 changes: 5 additions & 2 deletions .github/workflows/update-fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
CONFIG_FILE: ./DCTransistor/config.h
BI_CONFIG_FILE: ./DCTransistor-Bidirectional/config.h
outputs:
compile: ${{ steps.update-fingerprints.outputs.compile }}

Expand Down Expand Up @@ -41,13 +42,15 @@ jobs:
cur_fingerprint=$(get_current_fingerprint $server)
new_conf_string=$(echo -n "define ${fingerprint_var} \""${cur_fingerprint}"\"")
sed -i -e "s/${conf_string}/${new_conf_string}/" $CONFIG_FILE
sed -i -e "s/${conf_string}/${new_conf_string}/" ${CONFIG_FILE}
sed -i -e "s/${conf_string}/${new_conf_string}/" ${BI_CONFIG_FILE}
done
if [[ $(git status) != *"nothing to commit, working tree clean"* ]]; then
git config user.email "<>"
git config user.name "SSL Update Action"
git add $CONFIG_FILE
git add ${CONFIG_FILE}
git add ${BI_CONFIG_FILE}
git commit -m "Update SSL fingerprint"
git push origin main
echo "compile=true" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .vscode/arduino.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"board": "esp8266:esp8266:nodemcuv2",
"sketch": "DCTransistor/DCTransistor.ino",
"sketch": "DCTransistor-Bidirectional/DCTransistor-Bidirectional.ino",
"port": "/dev/ttyUSB0"
}
Loading

0 comments on commit 271c49b

Please sign in to comment.