In GitHub: automate Raspberry Pico project build verification with GitHub Actions , I made GitHub build a project. I'm using an Action to check out branches and build them, upon a GitHub event.
In this post, I create a GitHub action that will upload firmware to a GitHub release when changes are accepted on the development branch. I called it "nightly build", because my original intention was to run this once every night on the development branch sources. But at this moment, I made it trigger on "acceptance of code into the development branch" instead.
The result is that whenever the development branch manager accepts a pull request for that branch, the GitHub action is executed. And interested parties immediately have access to the firmware. They can drag-drop it onto their Pico.
Trigger Options
Initially, I wanted to have two triggers for executing the job: on demand, and daily, based on a cron schedule. But I'm not expecting daily (or even less frequent) changes once this project matures. Running the build every day (even though it is free for public projects) will burn calories. So I changed my mind, and replaced (commented out) the cron trigger. It will now run when changes are merged with the development branch.
name: Build on ubuntu against pico-sdk develop, and deploy to github prerelease on: # schedule: # - cron: '0 1 * * *' workflow_dispatch: push: branches: - 'develop'
How is it different from the build verification action?
I first designed GitHub: automate Raspberry Pico project build verification with GitHub Actions . That GitHub action will validate that new contributions will not break the code base, before the code is merged. And it is designed to work with every protected branch. The outcome is: true if the code builds. It's used as a guard for pull requests. If your code doesn't build correctly, the pull request will not merge.
The GitHub action in this post is different. It's a reaction to the successful merge of a pull request that targets the development branch. It doesn't guard or block anything. But it provides users with the latest "approved by the development manager" firmware.
Upload assets to a GitHub release via Actions
It's explained in the readme of the action that I use: pyTooling/Actions/releaser. Prerequisite is that you create a release (or as I did: pre-release) for your GitHub project first.
Here's the checkout and upload specific code. The rest is shared with the build.yml action I referred to above.
# ... - name: Checkout pico_gps_teseo uses: actions/checkout@v4 with: path: pico_gps_teseo ref: develop submodules: true " ... - name: Deploy Nightly Development Release uses: pyTooling/Actions/releaser@r0 with: token: ${{ secrets.GITHUB_TOKEN }} tag: nightly_development files: /home/runner/work/pico_gps_teseo/pico_gps_teseo/pico_gps_teseo/build/pico_gps_teseo_*.uf2
My build generates several .uf2 firmware binaries. An I2C and UART version of each of the examples in my project. How I do that, is a subject for follow-up post NMake and Raspberry Pico: generate multiple firmware binaries for the same code base . |
Link to all posts.