Automate manifest.json version updates during release #9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user
The shell variable
${V}will not be expanded within single quotes. This will result in the literal string"${V}"being written tomanifest.jsoninstead of the version number. To fix this, you should use double quotes for thesedexpression and escape the inner double quotes.Additionally,
sed -ibehaves differently on GNU/Linux versus macOS/BSD systems. For better portability, you might consider a different approach in the future, but fixing the variable expansion is the critical part.git push origin main v${V}pushes the localmainref, but the release commit is created on the current checked-out branch. If the user runsmake releasefrom a branch other thanmain, the tag will point to the release commit butorigin/mainwill not receive that commit (and could even push an outdated localmain). Consider either enforcing/releases frommain(fail if not onmainandgit pull --ff-only), or pushHEAD:mainalongside the tag so the commit you just made is what gets pushed.The
releaserecipe uses bash-only syntax ([[ ... ]]/=~) and GNUsed -isemantics. Since the Makefile doesn’t setSHELL := bash, this target can fail on systems where/bin/shisdash(common on Ubuntu) or wheresed -irequires a backup suffix (macOS/BSD). Consider settingSHELL := /usr/bin/env bash(or rewriting to POSIX sh) and using a portable in-place edit approach formanifest.json.