Skip to content

Release Rust Typ2Anki #19

Release Rust Typ2Anki

Release Rust Typ2Anki #19

Workflow file for this run

# .github/workflows/release.yml
name: Release Rust Typ2Anki
on:
workflow_dispatch:
permissions:
contents: write
id-token: write
attestations: write
packages: write
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Rust
run: rustup update stable && rustup default stable
- name: Install jq
run: sudo apt-get install -y jq
- name: Get Version
id: get_version
working-directory: ./typ2anki-rust
run: |
v=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[0].version")
echo "version=$v" >> $GITHUB_OUTPUT
- name: Check that tag does not exist
working-directory: ./typ2anki-rust
id: check_tag
run: |
if git rev-parse "refs/tags/v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1
then
echo "Tag v${{ steps.get_version.outputs.version }} already exists"
exit 1
else
echo "Tag v${{ steps.get_version.outputs.version }} does not exist, continuing"
fi
- name: Cargo Cache
uses: actions/cache@v4
id: cargo-cache-restore
with:
path: |
~/.cargo/registry
~/.cargo/git
./typ2anki-rust/target
key: ${{ runner.os }}-cargo-${{hashFiles('**/Cargo.toml')}}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-
${{ runner.os }}-cargo-
- name: Create Tag
working-directory: ./typ2anki-rust
run: |
git tag "v${{ steps.get_version.outputs.version }}"
- name: Set up Zig
uses: mlugg/setup-zig@v2
- name: Install cargo-binstall
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install zigbuild
run: |
cargo binstall \
-y --locked \
--pkg-url="{ repo }/releases/download/v{ version }/{ name }-v{ version }.{ target }.{ archive-format }" \
cargo-zigbuild
- name: Install strip
run: sudo apt-get install -y binutils
- name: Install mingw-w64
run: sudo apt-get install -y mingw-w64
- name: Install zip
run: sudo apt-get install -y zip
- name: Run GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
workdir: ./typ2anki-rust
distribution: goreleaser
version: "~> v2"
args: release --clean --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
_VERSION: "${{ steps.get_version.outputs.version }}"
- uses: actions/attest-build-provenance@v3
continue-on-error: true
with:
subject-checksums: ./typ2anki-rust/goreleaser-dist/checksums.txt
- name: Always Save Cargo Cache
id: cargo-cache-save
if: always() && steps.cargo-cache-restore.outputs.cache-hit != 'true' && steps.check_tag.outcome == 'success'
uses: actions/cache/save@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
./typ2anki-rust/target
key: ${{ runner.os }}-cargo-${{hashFiles('**/Cargo.toml')}}-${{ hashFiles('**/Cargo.lock') }}