Skip to content

Release

Release #68

Workflow file for this run

name: Release
on:
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
permissions:
contents: write
jobs:
setup-environment:
runs-on: ubuntu-latest
outputs:
git_tag_name: ${{ steps.git_tag_name.outputs.value }}
cargo_cache_key: ${{ steps.cargo_cache_key.outputs.value }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ github.ref }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Set cargo cache key
id: cargo_cache_key
run: |
CARGO_CACHE_KEY="${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
echo "value=$CARGO_CACHE_KEY" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
~/.cargo/bin
key: ${{ steps.cargo_cache_key.outputs.value }}
id: cache-cargo-release
- name: Set git_tag_name from latest Cargo.toml version
id: git_tag_name
run: |
VERSION=$(cargo read-manifest --manifest-path ./tinted-builder-rust/Cargo.toml | jq -r ".version")
echo "value=v$VERSION" >> $GITHUB_OUTPUT
- name: Ensure the release tag does not exist
run: |
version="${{ steps.git_tag_name.outputs.value }}"
if git rev-parse "$version" >/dev/null 2>&1; then
echo "This git tag already exists: $version"
exit 1
fi
- name: Ensure crate version doesn't already exist
run: |
crate_name="tinted-builder-rust"
version="${{ steps.git_tag_name.outputs.value }}"
response=$(curl -s "https://crates.io/api/v1/crates/$crate_name")
if echo "$response" | grep -q "\"num\":\"$version\""; then
echo "Version $version of $crate_name already exists."
exit 1
fi
lint:
needs: setup-environment
uses: ./.github/workflows/lint.yml
with:
cache-key: ${{ needs.setup-environment.outputs.cargo_cache_key }}
check-msrv:
uses: ./.github/workflows/msrv.yml
test:
needs: setup-environment
uses: ./.github/workflows/test.yml
with:
cache-key: ${{ needs.setup-environment.outputs.cargo_cache_key }}
tag-release:
needs:
- setup-environment
- check-msrv
- lint
- test
uses: ./.github/workflows/tag-release.yml
with:
git_tag_name: ${{ needs.setup-environment.outputs.git_tag_name }}
secrets:
DOCKER_GHCR: ${{ secrets.DOCKER_GHCR }}
create-release:
needs:
- setup-environment
- tag-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
ref: 'refs/tags/${{ needs.setup-environment.outputs.git_tag_name }}'
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
release:
needs: create-release
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- os: macos-11
target: x86_64-apple-darwin
- os: macos-11
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v4
- uses: taiki-e/upload-rust-binary-action@v1
with:
ref: 'refs/tags/${{ needs.setup-environment.outputs.git_tag_name }}'
bin: tinted-builder-rust
manifest-path: tinted-builder-rust/Cargo.toml
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
checksum: sha256
build-docker-image:
needs: release
uses: ./.github/workflows/push-ghcr-image.yml
with:
git_tag_name: v${{ needs.setup-environment.outputs.git_tag_name }}
secrets:
DOCKER_GHCR: ${{ secrets.DOCKER_GHCR }}
publish-crate:
needs: release
uses: ./.github/workflows/publish-crate.yml
secrets:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}