64 lines
2.0 KiB
YAML
64 lines
2.0 KiB
YAML
name: Create Release
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Release version (e.g., 1.2.3, without the 'v' prefix)"
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
create-release:
|
|
name: Create Release Tag
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Validate version format
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
run: |
|
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
|
|
echo "::error::Invalid version format '$VERSION'. Use X.X.X (e.g., 1.2.3)"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check out code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Check tag does not already exist
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
run: |
|
|
if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then
|
|
echo "::error::Tag v${VERSION} already exists"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Run tests
|
|
run: go test -race ./...
|
|
|
|
- name: Update manifest.json version
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
run: |
|
|
jq --arg v "$VERSION" '.version = $v' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
|
|
|
|
- name: Commit, tag, and push
|
|
env:
|
|
VERSION: ${{ inputs.version }}
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add manifest.json
|
|
git commit --allow-empty -m "Release v${VERSION}"
|
|
git tag "v${VERSION}"
|
|
git push origin main "v${VERSION}"
|