Skip to content

Commit

Permalink
Merge pull request #80 from augustozanellato/refactor_ci
Browse files Browse the repository at this point in the history
CI refactor
  • Loading branch information
doegox authored Aug 22, 2023
2 parents 27f2a40 + 4bdbb8d commit 989c723
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 67 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build_client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This is just a placeholder while the whole PyInstaller thing gets figured out
name: Client build

on:
workflow_call:
inputs:
checkout-sha:
required: false
type: string

jobs:
build_client:
name: Build client
strategy:
matrix:
include:
- name: windows
os: windows-latest
pre_command: |
? .
bundle_command: |
Compress-Archive -Path software\* -DestinationPath client-windows.zip
- name: linux
os: ubuntu-latest
pre_command: |
true
bundle_command: |
(cd software && zip -r "$OLDPWD/client-linux.zip" .)
- name: macos
os: macos-latest
pre_command: |
true
bundle_command: |
(cd software && zip -r "$OLDPWD/client-macos.zip" .)
runs-on: ${{ matrix.os }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
- name: Run OS specific setup
run: ${{ matrix.pre_command }}
- name: Upload built client
uses: actions/upload-artifact@v3
with:
name: client-${{ matrix.name }}
path: software/*
- name: Zip up client for release
run: ${{ matrix.bundle_command }}
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: client-${{ matrix.name }}.zip
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
name: Firmware build

on:
push:
paths-ignore:
- 'resource/**'
- 'hardware/**'
- 'software/**'
- '*.md'
pull_request:
paths-ignore:
- 'resource/**'
- 'hardware/**'
- 'software/**'
- '*.md'
workflow_call:
inputs:
checkout-sha:
required: false
type: string

jobs:
build_fw_builder:
Expand All @@ -28,6 +21,8 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Check out the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
- name: ghcr.io login
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -59,6 +54,8 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-sha == null && github.sha || inputs.checkout-sha }}
- name: Build firmware
env:
repo: ${{ github.repository }}
Expand All @@ -72,59 +69,22 @@ jobs:
- name: Unzip dfu images
run: |
sudo chown -R $USER:$USER firmware/objects
mkdir firmware/objects/dfu-app
mkdir firmware/objects/dfu-full
unzip firmware/objects/dfu-app.zip -d firmware/objects/dfu-app
unzip firmware/objects/dfu-full.zip -d firmware/objects/dfu-full
mkdir firmware/objects/${{ matrix.device_type }}-dfu-app
mkdir firmware/objects/${{ matrix.device_type }}-dfu-full
unzip firmware/objects/${{ matrix.device_type }}-dfu-app.zip -d firmware/objects/${{ matrix.device_type }}-dfu-app
unzip firmware/objects/${{ matrix.device_type }}-dfu-full.zip -d firmware/objects/${{ matrix.device_type }}-dfu-full
- name: Upload dfu app image
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.device_type }}-dfu-app
path: firmware/objects/dfu-app/*
path: firmware/objects/${{ matrix.device_type }}-dfu-app/*
- name: Upload dfu full image
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.device_type }}-dfu-full
path: firmware/objects/dfu-full/*
create_release:
permissions:
contents: write
name: Create Pre-Release with dfu app images
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs:
- build_fw
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download Ultra DFU
uses: actions/download-artifact@v3
with:
name: ultra-dfu-app
path: ultra-dfu-app
- name: Compress Ultra DFU package
run: |
zip --junk-paths -0 -r ./ultra-dfu-app.zip ./ultra-dfu-app/*
- name: Download Lite DFU
uses: actions/download-artifact@v3
with:
name: lite-dfu-app
path: lite-dfu-app
- name: Compress Lite DFU package
run: |
zip --junk-paths -0 -r ./lite-dfu-app.zip ./lite-dfu-app/*
- name: Upload to dev release
uses: softprops/action-gh-release@v1
path: firmware/objects/${{ matrix.device_type }}-dfu-full/*
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
body: |
Auto-Generated DFU packages from latest `main` commit.
For development purposes only.
These are not tested, here be dragons.
Built from commit ${{ github.sha }}
tag_name: dev
name: Development release
draft: false
prerelease: true
target_commitish: main
generate_release_notes: true
files: ./*-dfu-app.zip
name: release-artifacts
path: firmware/objects/*.zip
File renamed without changes.
44 changes: 44 additions & 0 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR handler
on:
pull_request_target:

jobs:
firmware_pipeline:
name: Build Firmware
permissions:
packages: write
contents: read
uses: ./.github/workflows/build_firmware.yml
with:
checkout-sha: "${{ github.event.pull_request.merge_commit_sha }}"
client_pipeline:
name: Build Firmware
uses: ./.github/workflows/build_client.yml
with:
checkout-sha: "${{ github.event.pull_request.merge_commit_sha }}"
comment:
runs-on: ubuntu-latest
name: Comment on PR
needs:
- firmware_pipeline
- client_pipeline
permissions:
pull-requests: write
steps:
- uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
# Built artifacts for commit ${{ github.event.pull_request.head.sha }}
## Firmware
- [Ultra APP DFU Package](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ultra-dfu-app.zip)
- [Ultra binaries](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/ultra-firmware.zip)
- [Lite APP DFU Package](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/lite-dfu-app.zip)
- [Lite binaries](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/lite-firmware.zip)
## Client
- [Linux](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-linux.zip)
- [macOS](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-macos.zip)
- [Windows](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/client-windows.zip)
51 changes: 51 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Push handler

on:
push:

jobs:
firmware_pipeline:
name: Build Firmware
permissions:
packages: write
contents: read
uses: ./.github/workflows/build_firmware.yml
client_pipeline:
name: Build Firmware
uses: ./.github/workflows/build_client.yml
create_release:
permissions:
contents: write
name: Create dev pre-release with artifacts
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs:
- firmware_pipeline
- client_pipeline
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download release artifacts
uses: actions/download-artifact@v3
with:
name: release-artifacts
path: release-artifacts
- name: Upload to dev release
uses: softprops/action-gh-release@v1
with:
body: |
Auto-Generated DFU packages from latest `main` commit.
For development purposes only.
These are not tested, here be dragons.
Built from commit ${{ github.sha }}
tag_name: dev
name: Development release
draft: false
prerelease: true
target_commitish: ${{ github.sha }}
generate_release_notes: true
files: release-artifacts/*
- name: Fix up release tag
run: |
git tag -f dev
git push --tags -f
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...

## [unreleased][unreleased]
- Refactor CI pipeline. (@augustozanellato)
- Added offline copy EM card uid for btnpress.(@nemanjan00)
- Added offline copy ic card uid for btnpress.(@xianglin1998)
- Added `hw settings btnpress` to get and set button press function.(@xianglin1998)
Expand Down
2 changes: 1 addition & 1 deletion firmware/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG NRF_CLT_URL=https://nsscprodmedia.blob.core.windows.net/prod/software-and-ot
RUN set -xe; \
DEBIAN_FRONTEND=noninteractive; \
apt update -q; \
apt install -qy --no-install-recommends ca-certificates curl xz-utils make git; \
apt install -qy --no-install-recommends ca-certificates curl xz-utils make git zip; \
git config --global --add safe.directory /workdir; \
curl -sLo /usr/bin/nrfutil https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil; \
curl -sLo /tmp/nrf-clt.deb $NRF_CLT_URL; \
Expand Down
25 changes: 18 additions & 7 deletions firmware/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,42 @@ set -xe

(
cd objects

cp ../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex softdevice.hex

nrfutil nrf5sdk-tools pkg generate \
--hw-version $hw_version \
--bootloader bootloader.hex --bootloader-version $bootloader_version --key-file ../../resource/dfu_key/chameleon.pem \
--application application.hex --application-version $application_version --app-boot-validation NO_VALIDATION \
--softdevice ../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex --sd-req ${softdevice_id} --sd-id ${softdevice_id} --sd-boot-validation NO_VALIDATION \
dfu-full.zip
--application application.hex --application-version $application_version\
--softdevice softdevice.hex \
--sd-req ${softdevice_id} --sd-id ${softdevice_id} \
${device_type}-dfu-full.zip

nrfutil nrf5sdk-tools pkg generate \
--hw-version $hw_version --key-file ../../resource/dfu_key/chameleon.pem \
--application application.hex --application-version $application_version --app-boot-validation NO_VALIDATION \
--application application.hex --application-version $application_version \
--sd-req ${softdevice_id} \
dfu-app.zip
${device_type}-dfu-app.zip

nrfutil nrf5sdk-tools settings generate \
--family NRF52840 \
--application application.hex --application-version $application_version \
--softdevice softdevice.hex \
--bootloader-version $bootloader_version --bl-settings-version 2 \
settings.hex
mergehex \
--merge \
settings.hex \
application.hex \
--output application.hex
rm settings.hex

mergehex \
--merge \
bootloader.hex \
settings.hex \
application.hex \
../nrf52_sdk/components/softdevice/${softdevice}/hex/${softdevice}_nrf52_${softdevice_version}_softdevice.hex \
softdevice.hex \
--output fullimage.hex

zip ${device_type}-binaries.zip *.hex
)

0 comments on commit 989c723

Please sign in to comment.