name: Publish Go FFI libs
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag (e.g. v0.1.0)"
required: true
permissions:
contents: write
concurrency:
group: release-go-${{ github.event.release.tag_name || inputs.tag }}
cancel-in-progress: false
jobs:
populate-and-tag:
runs-on: ubuntu-latest
steps:
- name: Determine tag
id: tag
env:
INPUT_TAG: ${{ inputs.tag }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
tag="${INPUT_TAG:-$RELEASE_TAG}"
if [[ -z "$tag" ]]; then
echo "::error::No tag from inputs or release event"
exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "Resolved tag: $tag"
- name: Filter non-version tags
id: filter
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
# Skip rolling dev tags, prior -go-suffix tags (legacy), and
# any retriggers on the bindings/go/* tags this workflow creates.
if [[ "$TAG" != v* ]] || [[ "$TAG" == *-go ]] || [[ "$TAG" == dev-* ]] || [[ "$TAG" == bindings/go/* ]]; then
echo "::notice::Skipping $TAG — not a versioned release tag"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v6
if: steps.filter.outputs.skip == 'false'
with:
ref: ${{ steps.tag.outputs.tag }}
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Populate FFI libs from GitHub release
if: steps.filter.outputs.skip == 'false'
env:
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
run: scripts/populate-go-libs.sh --github "${{ steps.tag.outputs.tag }}"
- name: Verify libs were staged
if: steps.filter.outputs.skip == 'false'
run: |
if git diff --cached --quiet; then
echo "::error::populate-go-libs.sh staged no files"
exit 1
fi
git diff --cached --stat
- name: Configure git identity
if: steps.filter.outputs.skip == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit + tag
if: steps.filter.outputs.skip == 'false'
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
git commit -m "release: $TAG Go FFI libs"
# Go-module tag for the bindings/go/ subdirectory module.
# See header comment for why this format (not $TAG-go).
MODTAG="bindings/go/$TAG"
git tag -a "$MODTAG" -m "Go binding $TAG — see CHANGELOG.md"
git push origin "$MODTAG"
echo "::notice::Pushed $MODTAG (commit $(git rev-parse HEAD))"