From 26fa18f2e3e8e75eba5e7fdaa74c8bd04eebf2aa Mon Sep 17 00:00:00 2001 From: Amayyas Date: Thu, 2 Jul 2026 16:34:14 +0200 Subject: [PATCH] ci: automate versioning and changelog with release-please - release-please-config.json + .release-please-manifest.json: node release type, keeps package.json and manifest.json versions in sync (extra-files jsonpath), plain v tags. - release-please.yml: maintains the release PR (version bump + CHANGELOG), and on merge builds + attaches the Chrome/Firefox zips to the created Release (done in-workflow since GITHUB_TOKEN releases don't trigger other workflows). - Remove release.yml: the tag-triggered release flow is now superseded by release-please (single mechanism). - README: Releases section updated to the release-please flow. Builds on the Conventional-Commit PR titles (#16) and the release zips (#12). --- .github/workflows/release-please.yml | 56 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 47 ----------------------- .release-please-manifest.json | 3 ++ README.md | 30 ++++++++------- release-please-config.json | 16 ++++++++ 5 files changed, 92 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/release-please.yml delete mode 100644 .github/workflows/release.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..d09d3a4 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,56 @@ +name: Release Please + +# Automated versioning + changelog. As Conventional-Commit changes land on +# main, release-please maintains a "release" PR that bumps the version +# (package.json + manifest.json) and updates CHANGELOG.md. Merging that PR tags +# the version and creates a GitHub Release; this workflow then builds the +# browser packages and attaches them to that Release. +# +# The build/upload runs in this same workflow (not a separate one triggered by +# the release) because releases created with GITHUB_TOKEN don't trigger further +# workflow runs. +on: + push: + branches: [main] + +concurrency: + group: release-please-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write # create the release + tag + pull-requests: write # open/update the release PR + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + # The steps below only run when the release PR was just merged. + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + if: ${{ steps.release.outputs.release_created == 'true' }} + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + if: ${{ steps.release.outputs.release_created == 'true' }} + with: + node-version: 20 + cache: npm + - name: Install dependencies + if: ${{ steps.release.outputs.release_created == 'true' }} + run: npm ci + - name: Build + package (Chrome + Firefox zips) + if: ${{ steps.release.outputs.release_created == 'true' }} + run: npm run package + - name: Attach zips to the release + if: ${{ steps.release.outputs.release_created == 'true' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release upload "${{ steps.release.outputs.tag_name }}" \ + focus-roast-chrome-*.zip \ + focus-roast-firefox-*.zip \ + --clobber diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 684df81..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Release - -# On a version tag (e.g. v0.1.0), build both browser packages, zip them and -# attach them to a GitHub Release so each version is downloadable/installable -# without a local build. Release notes are generated from the merged PRs. -on: - push: - tags: ["v*"] - -# Don't cancel a release that's already publishing. -concurrency: - group: release-${{ github.ref }} - cancel-in-progress: false - -permissions: - contents: write # create the release and upload assets - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: 20 - cache: npm - - name: Install dependencies - run: npm ci - - name: Check tag matches package.json version - run: | - TAG="${GITHUB_REF_NAME#v}" - PKG="$(node -p "require('./package.json').version")" - if [ "$TAG" != "$PKG" ]; then - echo "::error::Tag ${GITHUB_REF_NAME} does not match package.json version ${PKG}" - exit 1 - fi - - name: Build + package (Chrome + Firefox zips) - run: npm run package - - name: Create GitHub Release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create "$GITHUB_REF_NAME" \ - focus-roast-chrome-*.zip \ - focus-roast-firefox-*.zip \ - --title "$GITHUB_REF_NAME" \ - --generate-notes diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..466df71 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0" +} diff --git a/README.md b/README.md index 7f8d442..c30f985 100644 --- a/README.md +++ b/README.md @@ -241,16 +241,20 @@ change provider or key at any time via the ⚙ icon in the popup. ## Releases -Pre-built, ready-to-install packages for each version are attached to every -[GitHub Release](../../releases): `focus-roast-chrome-v.zip` (Chrome / -Edge / Brave / Opera) and `focus-roast-firefox-v.zip`. - -Releases are automated: pushing a `v` tag (matching `package.json`) -runs the [release workflow](.github/workflows/release.yml), which builds both -packages, zips them and publishes a Release with auto-generated notes. - -```bash -# cut a release once package.json + manifest.json are on the new version -git tag v0.2.0 -git push origin v0.2.0 -``` +Versioning and releases are automated with +[release-please](https://github.com/googleapis/release-please). As +Conventional-Commit changes (`feat:`, `fix:`, …) land on `main`, release-please +keeps a **release pull request** up to date that bumps the version in +`package.json` and `manifest.json` and updates `CHANGELOG.md`. + +Merging that release PR (see +[the workflow](.github/workflows/release-please.yml)): + +1. tags the version and creates a [GitHub Release](../../releases) with the + changelog notes; +2. builds both browser packages and attaches + `focus-roast-chrome-v.zip` (Chrome / Edge / Brave / Opera) and + `focus-roast-firefox-v.zip`. + +So every version stays downloadable and installable without a local build. To +preview the zips locally, run `npm run package`. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..949eb28 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "include-component-in-tag": false, + "packages": { + ".": { + "release-type": "node", + "extra-files": [ + { + "type": "json", + "path": "manifest.json", + "jsonpath": "$.version" + } + ] + } + } +}