From 2ee640a4488fc19bcffa88bd5fe2e8df8a36fefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20L=C3=BCtke?= Date: Fri, 25 Sep 2026 14:27:16 +0000 Subject: [PATCH] ci: read-only token for CI, and the release tag through the environment Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 4 ++++ .github/workflows/release.yml | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 717fdf4..e97abec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: [main] pull_request: +# Pull requests run here, so the token can read and nothing more. +permissions: + contents: read + concurrency: group: ci-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d20799..b3cc857 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,8 +33,12 @@ jobs: - name: Version id: version + # Through the environment, not spliced into the script: a tag typed + # into the dispatch form is text, never shell. + env: + TAG: ${{ inputs.tag || github.ref_name }} run: | - tag="${{ inputs.tag || github.ref_name }}" + tag="$TAG" version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) if [ "$tag" != "v$version" ]; then echo "tag $tag does not match Cargo.toml version $version" >&2 @@ -118,8 +122,12 @@ jobs: - name: Version id: version + # Through the environment, not spliced into the script: a tag typed + # into the dispatch form is text, never shell. + env: + TAG: ${{ inputs.tag || github.ref_name }} run: | - tag="${{ inputs.tag || github.ref_name }}" + tag="$TAG" version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) if [ "$tag" != "v$version" ]; then echo "tag $tag does not match Cargo.toml version $version" >&2