Skip to content

Semantic Versioning and Release #100

Semantic Versioning and Release

Semantic Versioning and Release #100

Workflow file for this run

name: Semantic Versioning and Release
on:
workflow_run:
workflows: ["CI"]
branches: ["main"]
types:
- completed
workflow_dispatch:
permissions:
issues: write
contents: write
id-token: write
pull-requests: write
jobs:
semantic-release:
name: Semantic Versioning and Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
tag: ${{ steps.version-release.outputs.tag }}
steps:
- name: Create temporary GitHub App Token
id: app
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.HOUSEKEEPING_BOT_APP_ID }}
private-key: ${{ secrets.HOUSEKEEPING_BOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout and setup
uses: alchemaxinc/composite-toolbox/checkout-and-setup@v1
with:
token: ${{ steps.app.outputs.token }}
- name: Version and release
id: version-release
uses: alchemaxinc/composite-toolbox/semantic-release@v1
with:
token: ${{ steps.app.outputs.token }}
- name: Check for changes
id: check_changes
uses: alchemaxinc/composite-toolbox/check-changes@v1
with:
files: "wrapper/Cargo.toml"
- name: Create Pull Request for version bump
id: open-pr
if: steps.check_changes.outputs.has_changes == 'true'
uses: alchemaxinc/composite-toolbox/create-pr@v1
with:
token: ${{ steps.app.outputs.token }}
base-branch: "main"
branch-prefix: "chore/auto/semantic-release"
files: "wrapper/Cargo.toml"
commit-message: "chore(semantic-release): bump version in wrapper/Cargo.toml"
pr-title: "chore: semantic release version bump"
pr-body: |
This PR updates the version in wrapper/Cargo.toml after semantic-release created a new release.
This is an automated PR created by the semantic release workflow.
- name: Auto-merge Pull Request
if: steps.open-pr.outcome == 'success'
uses: alchemaxinc/composite-toolbox/merge-pr@v1
with:
token: ${{ steps.app.outputs.token }}
merge-method: "merge"
pull-request-number: ${{ steps.open-pr.outputs.pr_number }}
build-and-upload:
name: Build ${{ matrix.target }}
needs: semantic-release
if: needs.semantic-release.outputs.tag != ''
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
runner: ubuntu-24.04
- target: aarch64-unknown-linux-musl
runner: ubuntu-24.04-arm
steps:
- name: Create temporary GitHub App Token
id: app
uses: actions/create-github-app-token@v3
with:
owner: ${{ github.repository_owner }}
client-id: ${{ vars.HOUSEKEEPING_BOT_APP_ID }}
private-key: ${{ secrets.HOUSEKEEPING_BOT_PRIVATE_KEY }}
- name: Checkout code
uses: actions/checkout@v6
- name: Read Rust toolchain version
id: rust-version
run: echo "version=$(grep '^channel' rust-toolchain.toml | sed 's/.*"\(.*\)".*/\1/')" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-version.outputs.version }}
targets: ${{ matrix.target }}
- name: Install musl tools
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Cache Cargo dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
wrapper/target
key: v1-release-${{ matrix.target }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('wrapper/Cargo.lock') }}
restore-keys: v1-release-${{ matrix.target }}-${{ hashFiles('rust-toolchain.toml') }}-
- name: Build binary
run: cargo build --manifest-path wrapper/Cargo.toml --release --target ${{ matrix.target }}
- name: Rename binary and generate checksum
run: |
cd wrapper/target/${{ matrix.target }}/release
mv wrapper wrapper-${{ matrix.target }}
sha256sum wrapper-${{ matrix.target }} > wrapper-${{ matrix.target }}.sha256
- name: Upload release assets
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
TAG: ${{ needs.semantic-release.outputs.tag }}
run: |
gh release upload "$TAG" \
"wrapper/target/${{ matrix.target }}/release/wrapper-${{ matrix.target }}" \
"wrapper/target/${{ matrix.target }}/release/wrapper-${{ matrix.target }}.sha256"
publish-release:
name: Publish release
needs: [semantic-release, build-and-upload]
runs-on: ubuntu-latest
steps:
- name: Create temporary GitHub App Token
id: app
uses: actions/create-github-app-token@v3
with:
owner: ${{ github.repository_owner }}
client-id: ${{ vars.HOUSEKEEPING_BOT_APP_ID }}
private-key: ${{ secrets.HOUSEKEEPING_BOT_PRIVATE_KEY }}
- name: Publish release
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
TAG: ${{ needs.semantic-release.outputs.tag }}
run: gh release edit "$TAG" --repo "${{ github.repository }}" --draft=false