Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- "README.md"
branches:
- main
tags:
- 'v*.*.*'
pull_request:
workflow_dispatch:

Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
push:
branches:
- prod
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 1.2.3, leave empty to auto-bump patch)'
required: false
type: string

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check for existing tag on HEAD
id: idempotency
run: |
EXISTING=$(git describe --exact-match --tags HEAD 2>/dev/null || true)
if echo "$EXISTING" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "HEAD is already tagged as $EXISTING — skipping release."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi

- name: Determine version
if: steps.idempotency.outputs.skip == 'false'
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
NEW_VERSION="v${{ inputs.version }}"
else
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
MAJOR=$(echo "${LATEST#v}" | cut -d. -f1)
MINOR=$(echo "${LATEST#v}" | cut -d. -f2)
PATCH=$(echo "${LATEST#v}" | cut -d. -f3)
NEW_VERSION="v${MAJOR}.${MINOR}.$((PATCH + 1))"
fi
echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
echo "Releasing ${NEW_VERSION}"

- name: Create and push tag
if: steps.idempotency.outputs.skip == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}

- name: Create GitHub Release
if: steps.idempotency.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.version.outputs.version }} \
--generate-notes \
--title "Release ${{ steps.version.outputs.version }}"
Loading