From c8107b5628c4f13627e0f4d26700a5c82f3bb8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20=C3=96sterberg?= Date: Sat, 24 Oct 2026 15:38:46 +0200 Subject: [PATCH 1/2] Limit GITHUB_TOKEN to read access by default in workflows The repository's default workflow token has write access, so every job, including the ones that only build and test, could push code, create releases or edit issues. If a step or a third party action in such a job is compromised, it gets the same access. Each workflow without a permissions block now starts with permissions: contents: read. Jobs that need to write get their own block: - create-release.yml: contents: write (creates the tag and GitHub release) - prep-release.yml: contents: write, pull-requests: write (peter-evans/create-pull-request pushes a branch and opens a PR) Changed: create-release.yml, linux.yml, manual-start.yml, prep-release.yml --- .github/workflows/create-release.yml | 5 +++++ .github/workflows/linux.yml | 3 +++ .github/workflows/manual-start.yml | 3 +++ .github/workflows/prep-release.yml | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index dd4d6b2..1379257 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -7,8 +7,13 @@ on: - main paths: - "package.json" +permissions: + contents: read + jobs: build: + permissions: + contents: write runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e1fcf0c..26b4960 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - main +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/manual-start.yml b/.github/workflows/manual-start.yml index 78e9340..499b6ba 100644 --- a/.github/workflows/manual-start.yml +++ b/.github/workflows/manual-start.yml @@ -9,6 +9,9 @@ on: type: string env: TEST_TAG: webperfse/webperf-core:test +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/prep-release.yml b/.github/workflows/prep-release.yml index af5cec4..e7e4b8b 100644 --- a/.github/workflows/prep-release.yml +++ b/.github/workflows/prep-release.yml @@ -7,8 +7,14 @@ on: - main paths: - "index.js" +permissions: + contents: read + jobs: build: + permissions: + contents: write + pull-requests: write runs-on: ubuntu-latest steps: - name: Checkout From bf426056be958070671c9f453192756108e86b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20=C3=96sterberg?= Date: Sat, 24 Oct 2026 15:40:42 +0200 Subject: [PATCH 2/2] Stop Create Release from releasing without a new version Create Release runs on every push to main that touches package.json. When package.json does not hold the next version, NEW_VERSION stays empty and the GitHub Release step fails. And when a push run and a manual run overlap, both release the same version and the release notes end up twice (seen in webperf_core 2026.10.2). - the release and publish steps now run only when NEW_VERSION is set, and a step says why the rest was skipped - runs are queued (concurrency group, no cancel), so a second run sees the new tag, computes the next version and publishes nothing --- .github/workflows/create-release.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 1379257..7fc6ebb 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -10,6 +10,12 @@ on: permissions: contents: read +# Queue runs instead of running them side by side, so a push and a manual +# run right after it can't both release the same version. +concurrency: + group: create-release + cancel-in-progress: false + jobs: build: permissions: @@ -36,13 +42,20 @@ jobs: - name: Generate new release version id: newversion run: python tools/release.py -l "${{ steps.changes.outputs.last-tag }}" + # NEW_VERSION stays empty when package.json does not hold the next + # version (any other change to package.json on main). + - name: Stop when there is no new version + if: env.NEW_VERSION == '' + run: echo "package.json does not hold a new version, nothing to release." - name: GitHub Release + if: env.NEW_VERSION != '' uses: softprops/action-gh-release@v3 with: tag_name: "${{ env.NEW_VERSION }}" make_latest: "true" generate_release_notes: true - name: NPM Release (version specific) + if: env.NEW_VERSION != '' uses: JS-DevTools/npm-publish@v4 with: token: ${{ secrets.NPM_TOKEN }}