Skip to content

Releasing refs/tags/v0.0.26 #39

Releasing refs/tags/v0.0.26

Releasing refs/tags/v0.0.26 #39

Workflow file for this run

name: Release
run-name: Releasing ${{ github.ref }}
permissions:
contents: write
id-token: write
attestations: write
on:
# Runs on a tag push
push:
tags:
- v[0-9]+.*
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
prepare-release-version:
name: Prepare release version
runs-on: ubuntu-latest
outputs:
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Get release version
run: |
RELEASE_VERSION=$(git describe --tags --broken --dirty --match v* 2>/dev/null || true)
[ -z "$RELEASE_VERSION" ] && \
RELEASE_VERSION=0.0.0-g$(git describe --tags --always --broken --dirty --match v*)
RELEASE_VERSION=${RELEASE_VERSION##v}
echo "RELEASE_VERSION=${RELEASE_VERSION}" | tee -a "$GITHUB_ENV"
build-and-test-binaries:
name: Build and test binaries
needs:
- prepare-release-version
uses: ./.github/workflows/build.yaml
with:
git_sha: ${{ github.sha }}
release_version: ${{ needs.prepare-release-version.outputs.release_version }}
sign: true
create-release:
name: Create release
runs-on: ubuntu-latest
needs:
- build-and-test-binaries
env:
RELEASE_VERSION: ${{ needs.build-and-test-binaries.outputs.release_version }}
outputs:
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Checkout current commit
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/binaries
- name: Get previous release tag
id: previous-release-tag
run: |
PREVIOUS_TAGS=$(git --no-pager tag --sort=creatordate --merged "${{ github.ref_name }}" 2>/dev/null | tail -n2)
if [[ -n "$PREVIOUS_TAGS" ]]; then
# There are tags, try and get the last one
echo >&2 "Found tags, getting the last one"
PREVIOUS_COMMIT=$(echo "$PREVIOUS_TAGS" ${{ startsWith(github.ref, 'refs/tags/v') && '|' || '| tail -n1 |' }} head -n1)
else
# There are no tags, let's just use the root commit
echo >&2 "Tags not found, using the root commit"
PREVIOUS_COMMIT=$(git rev-list --max-parents=0 "${{ github.ref_name }}")
fi
if [[ -z "$PREVIOUS_COMMIT" ]]; then
# There has been an issue
echo >&2 "Unable to resolve previous commit"
exit 1
fi
echo "ref=$PREVIOUS_COMMIT" | tee -a "$GITHUB_OUTPUT"
- name: Prepare release changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ github.sha }}
toTag: ${{ steps.previous-release-tag.outputs.ref }}
excludeTypes: build,docs,other,style,chore,test,tests,refactor
writeToFile: false
- name: Attest build provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: '/tmp/binaries/**/*'
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: v${{ env.RELEASE_VERSION }}
tag_name: v${{ env.RELEASE_VERSION }}
files: /tmp/binaries/**/*
fail_on_unmatched_files: true
body: ${{ steps.changelog.outputs.changes }}
publish-crate:
name: Publish crate
runs-on: ubuntu-latest
needs:
- create-release
env:
RELEASE_VERSION: ${{ needs.create-release.outputs.release_version }}
outputs:
release_version: ${{ env.RELEASE_VERSION }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: omni-build
- name: Override Cargo.toml and Cargo.lock version
run: |
perl -i -pe 's/^version = "0\.0\.0-git"$/version = "${{ env.RELEASE_VERSION }}"/' Cargo.toml
perl -i -pe 's/^version = "0\.0\.0-git"$/version = "${{ env.RELEASE_VERSION }}"/' Cargo.lock
- name: Publish crate
env:
OMNI_RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
run: |
# We use --allow-dirty since we override the version key
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --allow-dirty --verbose
- name: Reset Cargo.toml and Cargo.lock
run: |
git checkout Cargo.toml
git checkout Cargo.lock
update-brew:
name: Trigger brew formula update
runs-on: ubuntu-latest
needs:
- create-release
env:
HOMEBREW_REPOSITORY_OWNER: xaf
HOMEBREW_REPOSITORY_NAME: homebrew-omni
steps:
- name: Create application token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.OMNICLI_APP_ID }}
private-key: ${{ secrets.OMNICLI_PRIVATE_KEY }}
owner: ${{ env.HOMEBREW_REPOSITORY_OWNER }}
repositories: ${{ env.HOMEBREW_REPOSITORY_NAME }}
- name: Send repository dispatch with update-formulae event
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: ${{ env.HOMEBREW_REPOSITORY_OWNER }}/${{ env.HOMEBREW_REPOSITORY_NAME }}
event-type: update-formulae