Automate manifest.json version updates during release (#9)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Deluan Quintão
2026-02-07 20:17:09 -05:00
committed by GitHub
parent 982d3aae29
commit a39bcec7b2
3 changed files with 76 additions and 5 deletions

63
.github/workflows/create-release.yml vendored Normal file
View File

@@ -0,0 +1,63 @@
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}"

View File

@@ -16,6 +16,15 @@ jobs:
- name: Check out code
uses: actions/checkout@v5
- name: Verify manifest version matches tag
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
MANIFEST_VERSION=$(jq -r .version manifest.json)
if [ "$TAG_VERSION" != "$MANIFEST_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match manifest.json version ($MANIFEST_VERSION)"
exit 1
fi
- name: Set up Go
uses: actions/setup-go@v5
with:

View File

@@ -1,3 +1,4 @@
SHELL := /usr/bin/env bash
.PHONY: test build package clean
PLUGIN_NAME := discord-rich-presence
@@ -15,10 +16,8 @@ package: build
clean:
rm -f $(WASM_FILE) $(PLUGIN_NAME).ndp
release: test
release:
@if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi
go mod tidy
@if [ -n "`git status -s`" ]; then echo "\n\nThere are pending changes. Please commit or stash first"; exit 1; fi
git tag v${V}
git push origin v${V} --no-verify
gh workflow run create-release.yml -f version=${V}
@echo "Release v${V} workflow triggered. Check progress: gh run list --workflow=create-release.yml"
.PHONY: release