Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,45 @@ name: release

on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 0.6.1)'
required: true
type: string
push:
branches: [main]
paths:
- cmd/scip/version.txt

jobs:
publish:
setup:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
ref: main

- name: Validate version.txt
- id: resolve
run: |
if ! grep -q "${{ inputs.version }}" cmd/scip/version.txt; then
echo "::error::cmd/scip/version.txt doesn't match version ${{ inputs.version }}"
# tr strips CRLF, trailing whitespace, blank lines, etc.
VERSION=$(tr -d '[:space:]' < cmd/scip/version.txt)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::cmd/scip/version.txt ($VERSION) must be MAJOR.MINOR.PATCH"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

publish:
needs: setup
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ needs.setup.outputs.version }}
steps:
- uses: actions/checkout@v6
with:
ref: main

- name: Create and push tags
run: |
TAG="v${{ inputs.version }}"
TAG="v${{ needs.setup.outputs.version }}"
BINDINGS_TAG="bindings/go/scip/$TAG"
for t in "$TAG" "$BINDINGS_TAG"; do
if git rev-parse "$t" &>/dev/null; then
Expand All @@ -46,7 +59,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="v${{ inputs.version }}"
TAG="v${{ needs.setup.outputs.version }}"
if gh release view "$TAG" &>/dev/null; then
DRAFT=$(gh release view "$TAG" --json isDraft -q '.isDraft')
if [ "$DRAFT" = "false" ]; then
Expand Down Expand Up @@ -75,7 +88,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
ref: v${{ needs.publish.outputs.version }}
- uses: DeterminateSystems/nix-installer-action@v22
- uses: DeterminateSystems/magic-nix-cache-action@v14
with:
Expand All @@ -97,7 +110,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
ref: v${{ needs.publish.outputs.version }}
- uses: DeterminateSystems/nix-installer-action@v22
- uses: DeterminateSystems/magic-nix-cache-action@v14
with:
Expand Down Expand Up @@ -126,7 +139,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
ref: v${{ needs.publish.outputs.version }}

- uses: actions/setup-java@v5
with:
Expand Down Expand Up @@ -164,7 +177,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
ref: v${{ needs.publish.outputs.version }}
- uses: actions/setup-node@v6
with:
# Trusted publishing needs npm >=11.5.1; Node 22 LTS ships npm 10.x.
Expand Down Expand Up @@ -217,7 +230,7 @@ jobs:
steps:
- uses: actions/checkout@v6
with:
ref: v${{ inputs.version }}
ref: v${{ needs.publish.outputs.version }}
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
Expand All @@ -240,7 +253,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ matrix.asset_name }}
run: |
TAG="v${{ inputs.version }}"
TAG="v${{ needs.publish.outputs.version }}"
DRAFT=$(gh release view "$TAG" --json isDraft -q '.isDraft')
if [ "$DRAFT" = "false" ]; then
echo "::error::Release $TAG is already published, refusing to upload"
Expand All @@ -249,7 +262,7 @@ jobs:
gh release upload "$TAG" "$ASSET.tar.gz" "$ASSET.tar.gz.sha256" --clobber

finalize-release:
needs: [release-crate, publish-haskell-bindings, build-go-binaries, publish-jvm-bindings, publish-npm]
needs: [publish, release-crate, publish-haskell-bindings, build-go-binaries, publish-jvm-bindings, publish-npm]
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -258,4 +271,4 @@ jobs:
- name: Mark release as non-draft
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release edit "v${{ inputs.version }}" --draft=false
run: gh release edit "v${{ needs.publish.outputs.version }}" --draft=false