Automate manifest.json version updates during release (#9)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
63
.github/workflows/create-release.yml
vendored
Normal file
63
.github/workflows/create-release.yml
vendored
Normal 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}"
|
||||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
@@ -16,6 +16,15 @@ jobs:
|
|||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v5
|
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
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -1,3 +1,4 @@
|
|||||||
|
SHELL := /usr/bin/env bash
|
||||||
.PHONY: test build package clean
|
.PHONY: test build package clean
|
||||||
|
|
||||||
PLUGIN_NAME := discord-rich-presence
|
PLUGIN_NAME := discord-rich-presence
|
||||||
@@ -15,10 +16,8 @@ package: build
|
|||||||
clean:
|
clean:
|
||||||
rm -f $(WASM_FILE) $(PLUGIN_NAME).ndp
|
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
|
@if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi
|
||||||
go mod tidy
|
gh workflow run create-release.yml -f version=${V}
|
||||||
@if [ -n "`git status -s`" ]; then echo "\n\nThere are pending changes. Please commit or stash first"; exit 1; fi
|
@echo "Release v${V} workflow triggered. Check progress: gh run list --workflow=create-release.yml"
|
||||||
git tag v${V}
|
|
||||||
git push origin v${V} --no-verify
|
|
||||||
.PHONY: release
|
.PHONY: release
|
||||||
|
|||||||
Reference in New Issue
Block a user