Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Dec 12, 2024
1 parent e5e83cc commit b09dd48
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 18 deletions.
26 changes: 8 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ on:
# Run on the main branch
branches:
- main
# Releases are tags named 'v<version>', and must have the "major.minor.micro", for example: "0.1.0".
# Release candidates are tagged as `v<version>-rc<num>`, for example: "0.1.0-rc1".
tags:
- "v*"
# Also on PRs, just be careful not to publish anything
pull_request:


jobs:
ci:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: |
for p in firmware pinetime-flash watchful-ui; do
Expand All @@ -27,17 +23,17 @@ jobs:
done
publish:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install prerequisites
run: |
pip3 install adafruit-nrfutil
pip3 install -r tools/mcuboot/requirements.txt
cargo install cargo-binutils
- name: Build release artifacts
- name: Build artifacts
run: |
cd firmware
cargo build --release
Expand All @@ -46,25 +42,19 @@ jobs:
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application watchful-image.bin watchful-dfu.zip
- name: Upload binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: watchful.bin
path: firmware/watchful.bin

- name: Upload HEX
uses: actions/upload-artifact@v3
with:
name: watchful.hex
path: firmware/watchful.hex

- name: Upload Mcuboot image
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: watchful-image.bin
path: firmware/watchful-image.bin

- name: Upload DFU bundle
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: watchful-dfu.zip
path: firmware/watchful-dfu.zip
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write

jobs:
# Re Run the Checks
check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Build
run: |
for p in firmware pinetime-flash watchful-ui; do
pushd $p;
cargo build --release;
popd;
done
release:
# Only run if the checks pass
name: Publish to crates.io
needs: check
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Verify Version
run: |
cd firmware
TAG_VERSION=${GITHUB_REF#refs/tags/v}
CARGO_VERSION=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Version mismatch: tag is $TAG_VERSION but Cargo.toml is $CARGO_VERSION"
exit 1 # Exits with a non-zero status to fail the workflow
fi
shell: bash

- name: Install prerequisites
run: |
pip3 install adafruit-nrfutil
pip3 install -r tools/mcuboot/requirements.txt
cargo install cargo-binutils
- name: Build release artifacts
run: |
cd firmware
cargo build --release
cargo objcopy --release -- -O binary watchful.bin
../tools/mcuboot/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header watchful.bin watchful-image.bin
adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application watchful-image.bin watchful-dfu.zip
TAG_VERSION=${GITHUB_REF#refs/tags/v}
mv watchful-dfu.zip ../watchful-dfu-${TAG_VERSION}.zip
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes
watchful-dfu-${TAG_VERSION}.zip

0 comments on commit b09dd48

Please sign in to comment.