diff --git a/.github/workflows/build_client.yml b/.github/workflows/build_client.yml new file mode 100644 index 00000000..aabd58ff --- /dev/null +++ b/.github/workflows/build_client.yml @@ -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 diff --git a/.github/workflows/firmware.yml b/.github/workflows/build_firmware.yml similarity index 54% rename from .github/workflows/firmware.yml rename to .github/workflows/build_firmware.yml index e6058450..b584580d 100644 --- a/.github/workflows/firmware.yml +++ b/.github/workflows/build_firmware.yml @@ -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: @@ -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: @@ -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 }} @@ -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 diff --git a/.github/workflows/rebase.yml b/.github/workflows/changelog_reminder.yml similarity index 100% rename from .github/workflows/rebase.yml rename to .github/workflows/changelog_reminder.yml diff --git a/.github/workflows/on_pr.yml b/.github/workflows/on_pr.yml new file mode 100644 index 00000000..fe0ff3bd --- /dev/null +++ b/.github/workflows/on_pr.yml @@ -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) diff --git a/.github/workflows/on_push.yml b/.github/workflows/on_push.yml new file mode 100644 index 00000000..d5ef5dea --- /dev/null +++ b/.github/workflows/on_push.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 85d90d2f..b444f69a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/firmware/Dockerfile b/firmware/Dockerfile index 1646b91d..e9911613 100644 --- a/firmware/Dockerfile +++ b/firmware/Dockerfile @@ -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; \ diff --git a/firmware/build.sh b/firmware/build.sh index 66586598..907a2249 100755 --- a/firmware/build.sh +++ b/firmware/build.sh @@ -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 )