From 9ee12f2a31cbca8c6e0abd0f4d11a60c38c28f11 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Feb 2026 22:46:44 +0000 Subject: [PATCH 1/6] Automate manifest.json version updates during release Update `make release` to write the version into manifest.json and commit it before tagging, so the packaged artifact always carries the correct version. Also add a CI guard in the release workflow that fails early if the tag and manifest versions ever diverge. https://claude.ai/code/session_0158SxS2ATe6PL8zTpsoHRFn --- .github/workflows/release.yml | 9 +++++++++ Makefile | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 254cb09..aa86f9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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=$(grep -oP '"version"\s*:\s*"\K[^"]+' 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: diff --git a/Makefile b/Makefile index db8a4cd..fe8ffca 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,10 @@ release: test @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 + @# Update version in manifest.json + @sed -i 's/"version": *"[^"]*"/"version": "${V}"/' manifest.json + git add manifest.json + git commit -m "Release v${V}" --allow-empty --no-verify git tag v${V} - git push origin v${V} --no-verify + git push origin main v${V} --no-verify .PHONY: release -- 2.52.0 From 995f5737fc5fb0a8261ea9c5df721f9a73856cc8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Feb 2026 22:49:07 +0000 Subject: [PATCH 2/6] Add workflow_dispatch workflow to create releases from GitHub UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a "Create Release" workflow that can be triggered manually from the Actions tab. It takes a version string, validates the format, checks for duplicate tags, runs tests, updates manifest.json, commits, tags, and pushes — which then triggers the existing release workflow to build and publish the artifact. https://claude.ai/code/session_0158SxS2ATe6PL8zTpsoHRFn --- .github/workflows/create-release.yml | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000..487ecff --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,54 @@ +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 + run: | + if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then + echo "::error::Invalid version format '${{ inputs.version }}'. Use X.X.X (e.g., 1.2.3)" + exit 1 + fi + + - name: Check tag does not already exist + run: | + if git ls-remote --tags origin "refs/tags/v${{ inputs.version }}" | grep -q .; then + echo "::error::Tag v${{ inputs.version }} already exists" + exit 1 + fi + + - name: Check out code + uses: actions/checkout@v5 + + - 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 + run: sed -i 's/"version": *"[^"]*"/"version": "${{ inputs.version }}"/' manifest.json + + - name: Commit, tag, and push + 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 -m "Release v${{ inputs.version }}" + git tag "v${{ inputs.version }}" + git push origin main "v${{ inputs.version }}" -- 2.52.0 From e913e0988ff37a7dbbf069ffdf92cbb8f6f75561 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Feb 2026 22:59:04 +0000 Subject: [PATCH 3/6] Address PR review feedback - Add SHELL declaration to Makefile for bash compatibility - Add check that release is run from main branch - Use jq instead of grep -oP for JSON parsing in release.yml - Move checkout before git ls-remote in create-release.yml - Add --allow-empty to commit in create-release.yml https://claude.ai/code/session_0158SxS2ATe6PL8zTpsoHRFn --- .github/workflows/create-release.yml | 8 ++++---- .github/workflows/release.yml | 2 +- Makefile | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 487ecff..ccdbc4b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -23,6 +23,9 @@ jobs: exit 1 fi + - name: Check out code + uses: actions/checkout@v5 + - name: Check tag does not already exist run: | if git ls-remote --tags origin "refs/tags/v${{ inputs.version }}" | grep -q .; then @@ -30,9 +33,6 @@ jobs: exit 1 fi - - name: Check out code - uses: actions/checkout@v5 - - name: Set up Go uses: actions/setup-go@v5 with: @@ -49,6 +49,6 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add manifest.json - git commit -m "Release v${{ inputs.version }}" + git commit --allow-empty -m "Release v${{ inputs.version }}" git tag "v${{ inputs.version }}" git push origin main "v${{ inputs.version }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa86f9d..d53f4d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Verify manifest version matches tag run: | TAG_VERSION="${GITHUB_REF_NAME#v}" - MANIFEST_VERSION=$(grep -oP '"version"\s*:\s*"\K[^"]+' manifest.json) + 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 diff --git a/Makefile b/Makefile index fe8ffca..c0e0225 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +SHELL := /usr/bin/env bash .PHONY: test build package clean PLUGIN_NAME := discord-rich-presence @@ -19,6 +20,7 @@ release: test @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 + @if [[ "$$(git branch --show-current)" != "main" ]]; then echo "Releases must be created from the main branch"; exit 1; fi @# Update version in manifest.json @sed -i 's/"version": *"[^"]*"/"version": "${V}"/' manifest.json git add manifest.json -- 2.52.0 From 32b623f59dd16f4a1cba3e2dbde305960394a47d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Feb 2026 23:59:58 +0000 Subject: [PATCH 4/6] Simplify make release to trigger the GitHub workflow Instead of duplicating the release logic locally, `make release` now just validates the version format and triggers the create-release workflow via `gh workflow run`. https://claude.ai/code/session_0158SxS2ATe6PL8zTpsoHRFn --- Makefile | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c0e0225..2a74ccb 100644 --- a/Makefile +++ b/Makefile @@ -16,15 +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 - @if [[ "$$(git branch --show-current)" != "main" ]]; then echo "Releases must be created from the main branch"; exit 1; fi - @# Update version in manifest.json - @sed -i 's/"version": *"[^"]*"/"version": "${V}"/' manifest.json - git add manifest.json - git commit -m "Release v${V}" --allow-empty --no-verify - git tag v${V} - git push origin main 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 -- 2.52.0 From ede7856bdb1a0a5a91e8ef2517733dd74fa32ca2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Feb 2026 01:09:10 +0000 Subject: [PATCH 5/6] Fix YAML syntax error in create-release workflow The sed pattern with `*` on a single-line `run:` was interpreted as a YAML alias. Switch to a block scalar (`run: |`) to avoid this. --- .github/workflows/create-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index ccdbc4b..7b4f23a 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -42,7 +42,8 @@ jobs: run: go test -race ./... - name: Update manifest.json version - run: sed -i 's/"version": *"[^"]*"/"version": "${{ inputs.version }}"/' manifest.json + run: | + sed -i 's/"version": *"[^"]*"/"version": "${{ inputs.version }}"/' manifest.json - name: Commit, tag, and push run: | -- 2.52.0 From 63ab3ec57e82ae863895ae2a2fc79abcb1d4336c Mon Sep 17 00:00:00 2001 From: deluan Date: Sat, 7 Feb 2026 20:15:29 -0500 Subject: [PATCH 6/6] Fix script injection and use jq for manifest updates Use environment variables instead of direct ${{ inputs.version }} interpolation in shell scripts to prevent script injection. Switch from sed to jq for updating manifest.json, consistent with how release.yml already reads the version. --- .github/workflows/create-release.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 7b4f23a..a4b6deb 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -17,9 +17,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Validate version format + env: + VERSION: ${{ inputs.version }} run: | - if [[ ! "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then - echo "::error::Invalid version format '${{ inputs.version }}'. Use X.X.X (e.g., 1.2.3)" + 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 @@ -27,9 +29,11 @@ jobs: 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${{ inputs.version }}" | grep -q .; then - echo "::error::Tag v${{ inputs.version }} already exists" + if git ls-remote --tags origin "refs/tags/v${VERSION}" | grep -q .; then + echo "::error::Tag v${VERSION} already exists" exit 1 fi @@ -42,14 +46,18 @@ jobs: run: go test -race ./... - name: Update manifest.json version + env: + VERSION: ${{ inputs.version }} run: | - sed -i 's/"version": *"[^"]*"/"version": "${{ inputs.version }}"/' manifest.json + 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${{ inputs.version }}" - git tag "v${{ inputs.version }}" - git push origin main "v${{ inputs.version }}" + git commit --allow-empty -m "Release v${VERSION}" + git tag "v${VERSION}" + git push origin main "v${VERSION}" -- 2.52.0