Skip to content

release

release #2

Workflow file for this run

name: release
run-name: release
on:
push:
# TODO: automated releases triggered by tags won't work until a
# PAT is used to push tags (or a tag is pushed manually)
tags:
- "webidl2wit-v[0-9]+.[0-9]+.[0-9]+*"
- "webidl2wit-v[0-9]+.[0-9]+.[0-9]+-*"
- "webidl2wit-cli-v[0-9]+.[0-9]+.[0-9]+*"
- "webidl2wit-cli-v[0-9]+.[0-9]+.[0-9]+-*"
branches:
- "prep-release-v[0-9]+.[0-9]+.[0-9]+*"
- "prep-release-v[0-9]+.[0-9]+.[0-9]+-*"
workflow_dispatch:
inputs:
project:
type: choice
required: true
default: "webidl2wit"
description: |
Project to release via tag
options:
- webidl2wit
- webidl2wit-cli
version:
type: string
required: true
description: |
Versoin tag to release (e.x. `0.1.0`, `0.2.0`)
jobs:
meta:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.meta.outputs.version }}
project: ${{ steps.meta.outputs.project }}
steps:
- name: Collect metadata
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: meta
with:
script: |
if (context.payload.inputs.project && context.payload.inputs.version) {
core.setOutput('project', context.payload.inputs.project);
core.setOutput('version', context.payload.inputs.version);
return;
}
if (context.ref.startsWith('refs/tags')) {
match = tag.replace(/^refs\/tags\//, '').match(/^(.*)-v(\d+\.\d+\.\d+)$/);
} else if (context.ref.startsWith('refs/heads')) {
match = tag.replace(/^refs\/heads\//, '').match(/^prep-release-(.+)-v(\d+\.\d+\.\d+)$/);
} else {
throw new Error(`Unexpected context ref [${context.ref}]`);
}
if (!match) { throw new Error(`Failed to parse tag/branch: [${context.ref}]`); }
const [_, project, version] = match;
core.setOutput('project', project);
core.setOutput('version', version);
release-crate:
runs-on: ubuntu-24.04
needs:
- meta
permissions:
contents: write
steps:
# Checkout the repository
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: taiki-e/install-action@d125c0a83576d3c0c86ac610c708b38d3565af4e # v2.47.15
with:
fallback: none
tool: git-cliff
- name: Generate current changelog
working-directory: crates/${{ needs.meta.outputs.project }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export TAG=${{ needs.meta.outputs.project }}-${{ needs.meta.outputs.version }}
git cliff --repository=../../ --tag=$TAG > CHANGELOG.current
- name: Release crate (dry run)
if: ${{ startsWith(github.ref, 'refs/heads/prep-release') }} # release prep branch
working-directory: crates/${{ needs.meta.outputs.project }}
run: |
cargo publish --locked --dry-run
- name: Release crate to crates.io
if: ${{ startsWith(github.ref, 'refs/tags') || github.event_name == 'workflow_dispatch' }} # release tag
working-directory: crates/${{ needs.meta.outputs.project }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --locked
gh-release-lib:
if: ${{ needs.meta.outputs.project == 'webidl2wit' }}
runs-on: ubuntu-24.04
needs:
- meta
- release-crate
steps:
# Checkout the repository
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: taiki-e/install-action@d125c0a83576d3c0c86ac610c708b38d3565af4e # v2.47.15
with:
fallback: none
tool: git-cliff
- name: Generate current changelog
working-directory: crates/${{ needs.meta.outputs.project }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: |
export TAG=${{ needs.meta.outputs.project }}-${{ needs.meta.outputs.version }}
git cliff --repository=../../ --tag=$TAG > CHANGELOG.current
- name: Create GH release
if: ${{ needs.meta.outputs.project == 'webidl2wit' }}
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
prerelease: ${{ startsWith(github.ref, 'refs/heads/prep-release') }}
draft: ${{ startsWith(github.ref, 'refs/heads/prep-release') }}
tag_name: ${{ needs.meta.outputs.project }}-v${{ needs.meta.outputs.version }}
generate_release_notes: false
body_path: crates/${{ needs.meta.outputs.project }}/CHANGELOG.current
gh-release-build-cli:
if: ${{ needs.meta.outputs.project == 'webidl2wit-cli' }}
runs-on: ubuntu-24.04
needs:
- meta
- release-crate
strategy:
matrix:
platform:
- triple: x86_64-unknown-linux-gnu
runs-on: ubuntu-24.04
bin-name: webidl2wit
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: taiki-e/install-action@d125c0a83576d3c0c86ac610c708b38d3565af4e # v2.47.15
with:
fallback: none
tool: cargo-zigbuild
- uses: mlugg/setup-zig@a67e68dc5c8281d9608136d3d7ca1b282213e4ac # v1.2.1
- name: build
run: |
cargo zigbuild -p ${{ needs.meta.outputs.project }} --target=${{ matrix.platform.triple }} --release
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
path: target/${{ matrix.platform.triple }}/release/${{ matrix.platform.bin-name }}
if-no-files-found: error
gh-release-cli:
if: ${{ needs.meta.outputs.project == 'webidl2wit-cli' }}
runs-on: ubuntu-24.04
needs:
- meta
- gh-release-build-cli
steps:
# Checkout the repository
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: taiki-e/install-action@d125c0a83576d3c0c86ac610c708b38d3565af4e # v2.47.15
with:
fallback: none
tool: git-cliff
- name: Generate current changelog
working-directory: crates/${{ needs.meta.outputs.project }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: |
export TAG=${{ needs.meta.outputs.project }}-${{ needs.meta.outputs.version }}
git cliff --repository=../../ --tag=$TAG > CHANGELOG.current
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
if: ${{ inputs.project == 'webidl2wit-cli' }}
with:
path: artifacts
- name: Create GH release
if: ${{ needs.meta.outputs.project == 'webidl2wit-cli' }}
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
with:
prerelease: ${{ startsWith(github.ref, 'refs/heads/prep-release') }}
draft: ${{ startsWith(github.ref, 'refs/heads/prep-release') }}
tag_name: ${{ needs.meta.outputs.project }}-v${{ needs.meta.outputs.version }}
generate_release_notes: false
body_path: crates/${{ needs.meta.outputs.project }}/CHANGELOG.current
files: |
./artifacts/*/*