diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bc5abf..ce102a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,9 @@ name: Build on: push: - tags: ["v*"] + branches: [main] + pull_request: + branches: [main] jobs: build: @@ -24,29 +26,3 @@ jobs: - name: Build Chrome zip run: make build - - - - name: Build Firefox xpi - run: | - npx web-ext build --source-dir=. --artifacts-dir=. \ - --ignore-files="node_modules/*" "test/*" "demo/*" "*.svg" \ - "package*.json" "eslint.config.*" ".github/*" "AGENTS.md" \ - "CLAUDE.md" "CHANGELOG.md" "PRIVACY.md" "README.md" ".gitignore" \ - ".node-version" "docs/*" "Makefile" - mv github_pr_dashboard-*.zip github-pr-dashboard-firefox-unsigned.xpi - - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - files: | - github-pr-dashboard-chrome.zip - github-pr-dashboard-firefox-unsigned.xpi - generate_release_notes: true - append_body: true - body: | - ## Install - - | Browser | File | Notes | - |---------|------|-------| - | Chrome | `github-pr-dashboard-chrome.zip` | Unzip, then Load unpacked in `chrome://extensions` | - | Firefox | `github-pr-dashboard-firefox-unsigned.xpi` | **Unsigned** — works as a temporary add-on only (removed on browser close). For a persistent install, use the signed version from [addons.mozilla.org](https://addons.mozilla.org) when available. | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c5839cd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: ["v*"] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + + - run: npm ci + + - name: Lint + run: npx eslint *.js + + - name: Test + run: npm test + + - name: Build Chrome zip + run: make build + + - name: Build Firefox xpi + run: | + npx web-ext build --source-dir=. --artifacts-dir=. \ + --ignore-files="node_modules/*" "test/*" "demo/*" "*.svg" \ + "package*.json" "eslint.config.*" ".github/*" "AGENTS.md" \ + "CLAUDE.md" "CHANGELOG.md" "PRIVACY.md" "README.md" ".gitignore" \ + ".node-version" "docs/*" "Makefile" + mv github_pr_dashboard-*.zip github-pr-dashboard-firefox-unsigned.xpi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: | + github-pr-dashboard-chrome.zip + github-pr-dashboard-firefox-unsigned.xpi + generate_release_notes: true + append_body: true + body: | + ## Install + + | Browser | File | Notes | + |---------|------|-------| + | Chrome | `github-pr-dashboard-chrome.zip` | Unzip, then Load unpacked in `chrome://extensions` | + | Firefox | `github-pr-dashboard-firefox-unsigned.xpi` | **Unsigned** — works as a temporary add-on only (removed on browser close). For a persistent install, use the signed version from [addons.mozilla.org](https://addons.mozilla.org) when available. | diff --git a/Makefile b/Makefile index bcb684e..ed41fe6 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .DEFAULT_GOAL := menu -.PHONY: menu install test lint ci build demo release help list +.PHONY: menu install test lint ci build demo release tag help list # Colors CYAN := \033[36m @@ -31,8 +31,9 @@ menu: @printf " $(YELLOW)5)$(RESET) make ci $(DIM)Run lint + test + build (CI pipeline)$(RESET)\n" @printf "\n" @printf " $(BOLD)$(GREEN)=== Release ===$(RESET)\n" - @printf " $(YELLOW)6)$(RESET) make release $(DIM)Bump version, tag, and push$(RESET)\n" - @printf " $(YELLOW)7)$(RESET) make demo $(DIM)Build demo extension for screenshots$(RESET)\n" + @printf " $(YELLOW)6)$(RESET) make release $(DIM)Bump version and create PR$(RESET)\n" + @printf " $(YELLOW)7)$(RESET) make tag $(DIM)Tag merged release and push$(RESET)\n" + @printf " $(YELLOW)8)$(RESET) make demo $(DIM)Build demo extension for screenshots$(RESET)\n" @printf "\n" @read -p " Enter choice: " choice; \ case $$choice in \ @@ -42,7 +43,8 @@ menu: 4) $(MAKE) install ;; \ 5) $(MAKE) ci ;; \ 6) $(MAKE) release ;; \ - 7) $(MAKE) demo ;; \ + 7) $(MAKE) tag ;; \ + 8) $(MAKE) demo ;; \ *) echo "Invalid choice" ;; \ esac @@ -97,20 +99,28 @@ release: esac; \ if [ -z "$$VERSION" ]; then echo "Aborted."; exit 1; fi; \ printf "\n$(BOLD)Releasing $(CYAN)v$$VERSION$(RESET)\n\n"; \ + BRANCH="release/v$$VERSION"; \ + git checkout main; \ + git pull --ff-only origin main; \ + if [ -n "$$(git status --porcelain)" ]; then echo "Working tree not clean"; exit 1; fi; \ + git checkout -b "$$BRANCH"; \ node -e "var p=require('./package.json');p.version='$$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\n')"; \ sed -i 's/"version": ".*"/"version": "'"$$VERSION"'"/' manifest.json; \ $(MAKE) ci; \ git add package.json manifest.json; \ git commit -m "Release v$$VERSION"; \ - git tag "v$$VERSION"; \ - printf "\n$(BOLD)$(GREEN)Tagged v$$VERSION$(RESET)\n"; \ - read -p "Push to remote? [y/N] " PUSH; \ - if [ "$$PUSH" = "y" ] || [ "$$PUSH" = "Y" ]; then \ - git push && git push --tags; \ - printf "$(BOLD)$(GREEN)Pushed. GitHub Actions will create the release.$(RESET)\n"; \ - else \ - printf "Run $(CYAN)git push && git push --tags$(RESET) when ready.\n"; \ - fi + git push -u origin "$$BRANCH"; \ + gh pr create --title "Release v$$VERSION" --body "Bump version to $$VERSION" --base main; \ + printf "\n$(BOLD)$(GREEN)PR created for v$$VERSION$(RESET)\n"; \ + printf " After merging, run: $(CYAN)make tag VERSION=$$VERSION$(RESET)\n\n" + +tag: + @if [ -z "$(VERSION)" ]; then echo "Usage: make tag VERSION=x.y.z"; exit 1; fi + @git checkout main + @git pull + @git tag "v$(VERSION)" + @git push origin "v$(VERSION)" + @printf "\n$(BOLD)$(GREEN)Tagged v$(VERSION) — GitHub Actions will create the release.$(RESET)\n" help: @printf "\n" @@ -121,7 +131,8 @@ help: @printf " $(CYAN)make build$(RESET) Create distributable zip\n" @printf " $(CYAN)make install$(RESET) Install dev dependencies\n" @printf " $(CYAN)make ci$(RESET) Run lint + test + build\n" - @printf " $(CYAN)make release$(RESET) Bump version, tag, and push\n" + @printf " $(CYAN)make release$(RESET) Bump version and create PR\n" + @printf " $(CYAN)make tag$(RESET) Tag merged release and push\n" @printf " $(CYAN)make demo$(RESET) Build demo extension for screenshots\n" @printf "\n" diff --git a/README.md b/README.md index 3b31e58..dfba7fe 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,8 @@ make lint # Run ESLint make build # Create distributable zip make ci # All of the above make demo # Build demo extension for screenshots -make release # Interactive version bump, tag, and push +make release # Bump version and create PR +make tag # Tag merged release and push ``` ## License