Skip to content

Continuous Integration #60

Continuous Integration

Continuous Integration #60

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [main]
tags: ['v*']
pull_request:
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo "github.ref = ${{ github.ref }}"
echo "github.event_name = ${{ github.event_name }}"
- name: Checkout source
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
components: rustfmt
- name: Check format
run: cargo fmt --all -- --check
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
- run: cargo install flip-link --version 0.1.9
- run: cargo check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
components: clippy
- name: Check clippy
run: cargo clippy --all-features --locked -- -D warnings
release:
name: Release
runs-on: ubuntu-latest
needs: [check, format, clippy]
if: startsWith(github.ref, 'refs/tags/v')
outputs:
version: ${{ steps.get-version.outputs.filename }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
- run: cargo install flip-link --version 0.1.9
- run: cargo install cargo-binutils
- run: |
# required by binutils
rustup component add llvm-tools-preview
- name: Get tag version
id: get-tag
run: |
# Remove 'v' prefix from tag
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "tag_version=${TAG_VERSION}" >> $GITHUB_OUTPUT
- name: Get Cargo.toml version
id: get-cargo-version
run: |
CARGO_VERSION=$(grep -m1 '^version\s*=' Cargo.toml | cut -d'"' -f2)
echo "cargo_version=${CARGO_VERSION}" >> $GITHUB_OUTPUT
- name: Compare versions
id: get-version
run: |
TAG_VERSION="${{ steps.get-tag.outputs.tag_version }}"
CARGO_VERSION="${{ steps.get-cargo-version.outputs.cargo_version }}"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Version mismatch!"
echo "Tag version: $TAG_VERSION"
echo "Cargo.toml version: $CARGO_VERSION"
exit 1
fi
echo "version=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "Versions match: ${TAG_VERSION}"
echo "filename=umi-adapter-v${TAG_VERSION}.bin" >> $GITHUB_OUTPUT
- run: cargo objcopy --release -- -O binary ${{ steps.get-version.outputs.filename }}
- name: Install dfu-utils
run: sudo apt-get install -y dfu-util
- run: dfu-suffix --vid 1209 --pid 2323 --add ${{ steps.get-version.outputs.filename }}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-version.outputs.filename }}
path: ${{ steps.get-version.outputs.filename }}
if-no-files-found: error
announce:
name: Announce
runs-on: ubuntu-latest
permissions:
contents: write
needs: [release]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/*"