name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
permissions:
contents: write
id-token: write
checks: read
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Extract changelog for this version
id: changelog
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Extract changelog section for this version
if [ -f CHANGELOG.md ]; then
CHANGELOG=$(awk -v ver="$VERSION" '
/^## \['"$VERSION"'\]/ { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md)
fi
if [ -z "$CHANGELOG" ]; then
echo "WARNING: No changelog entry found for version $VERSION"
CHANGELOG="See commit history for details."
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
wait-for-ci:
name: Wait for CI Workflows
needs: prepare-release
runs-on: ubuntu-22.04
steps:
- name: Wait for Build workflow
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.sha }}
check-name: 'Build (x86_64)'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Wait for Build workflow (aarch64)
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.sha }}
check-name: 'Build (aarch64)'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Wait for SBOM workflow
uses: lewagon/wait-on-check-action@v1.3.4
with:
ref: ${{ github.sha }}
check-name: 'Generate SBOM & Check License Compliance'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-22.04
needs:
- prepare-release
- wait-for-ci
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts from commit
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
commit: ${{ github.sha }}
path: artifacts
- name: Download SBOM artifact from commit
uses: dawidd6/action-download-artifact@v6
with:
workflow: sbom.yml
commit: ${{ github.sha }}
path: artifacts
- name: Organize release assets
run: |
mkdir -p release-assets
VERSION=${{ needs.prepare-release.outputs.version }}
# Copy x86_64 binary
if [ -f artifacts/packages-x86_64/edgefirst-imu-x86_64 ]; then
cp artifacts/packages-x86_64/edgefirst-imu-x86_64 \
release-assets/edgefirst-imu-linux-x86_64
fi
# Copy ARM64 binary
if [ -f artifacts/packages-aarch64/edgefirst-imu-aarch64 ]; then
cp artifacts/packages-aarch64/edgefirst-imu-aarch64 \
release-assets/edgefirst-imu-linux-aarch64
fi
# Copy SBOM
if [ -f artifacts/sbom/sbom.json ]; then
cp artifacts/sbom/sbom.json \
release-assets/edgefirst-imu-v${VERSION}-sbom.json
fi
echo "Release assets prepared:"
ls -lh release-assets/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: EdgeFirst IMU v${{ needs.prepare-release.outputs.version }}
body: |
# EdgeFirst IMU v${{ needs.prepare-release.outputs.version }}
## Installation
### From crates.io (Recommended)
```bash
cargo install edgefirst-imu
```
### Download Binaries
| Platform | Binary |
|----------|--------|
| Linux x86_64 | `edgefirst-imu-linux-x86_64` |
| Linux ARM64 | `edgefirst-imu-linux-aarch64` |
```bash
# Download and install (ARM64 example)
wget https://github.com/EdgeFirstAI/imu/releases/download/v${{ needs.prepare-release.outputs.version }}/edgefirst-imu-linux-aarch64
chmod +x edgefirst-imu-linux-aarch64
sudo mv edgefirst-imu-linux-aarch64 /usr/local/bin/edgefirst-imu
```
## What's Changed
${{ needs.prepare-release.outputs.changelog }}
---
**Full Documentation**: https://github.com/EdgeFirstAI/imu#readme
files: |
release-assets/*
draft: false
prerelease: ${{ contains(needs.prepare-release.outputs.version, '-') }}
fail_on_unmatched_files: false
publish-crates:
name: Publish to crates.io
runs-on: ubuntu-22.04
needs:
- prepare-release
- create-github-release
environment: crates-io
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish