name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
jobs:
ci:
uses: ./.github/workflows/ci.yml
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get tag version
id: tag
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Validate version matches
run: |
CARGO_VERSION=$(grep '^version' orb8-cli/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
if [ "$CARGO_VERSION" != "${{ steps.tag.outputs.version }}" ]; then
echo "Tag version (${{ steps.tag.outputs.version }}) doesn't match orb8-cli/Cargo.toml ($CARGO_VERSION)"
exit 1
fi
publish:
needs: [ci, validate]
runs-on: ubuntu-latest
environment: "Crates publishing"
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Get OIDC token
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish crates
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: |
# Publish in dependency order, skip already-published versions
cargo publish -p orb8-common || true
sleep 15
cargo publish -p orb8-proto || true
sleep 15
cargo publish -p orb8-cli || true
sleep 15
cargo publish -p orb8-agent || true
sleep 15
cargo publish -p orb8 || true
release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Extract changelog
id: changelog
run: |
VERSION=${GITHUB_REF#refs/tags/v}
NOTES=$(sed -n "/## \[${VERSION}\]/,/## \[/p" CHANGELOG.md | head -n -1 || echo "Release ${VERSION}")
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.notes }}
generate_release_notes: true