From 1c0aa1bdb85200399892524fe5cd947bb87e6a24 Mon Sep 17 00:00:00 2001 From: Manuel Schiller <6340397+schiller-manuel@users.noreply.github.com> Date: Sun, 29 Nov 2026 17:32:46 +0100 Subject: [PATCH 1/4] ci: version the shared actions with release tags Consumers pin the shared actions as `@ # main`, and zizmor's `ref-version-mismatch` audit fails in every one of them as soon as `main` moves here, even when no action changed. Add a workflow that creates a `vX.Y.Z` release when one of the action directories changes, so consumers can pin `@ # vX.Y.Z` instead. Co-Authored-By: Claude Fable 5.2 --- .github/comment-on-release/README.md | 4 +- .github/workflows/release-actions.yml | 92 +++++++++++++++++++++++++++ docs/ci-cd.md | 30 +++++++++ 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-actions.yml diff --git a/.github/comment-on-release/README.md b/.github/comment-on-release/README.md index cff4576f..eebaf946 100644 --- a/.github/comment-on-release/README.md +++ b/.github/comment-on-release/README.md @@ -51,11 +51,13 @@ Add this step to your `.github/workflows/release.yml` file after the `changesets - name: Comment on PRs about release if: steps.changesets.outputs.published == 'true' - uses: TanStack/config/.github/comment-on-release@main + uses: TanStack/config/.github/comment-on-release@ # v1.0.0 with: published-packages: ${{ steps.changesets.outputs.published-packages }} ``` +Use the commit and version of the latest "Actions vX.Y.Z" [release](https://github.com/TanStack/config/releases). + ## Requirements - Must be using [Changesets](https://github.com/changesets/changesets) for releases diff --git a/.github/workflows/release-actions.yml b/.github/workflows/release-actions.yml new file mode 100644 index 00000000..fd34be85 --- /dev/null +++ b/.github/workflows/release-actions.yml @@ -0,0 +1,92 @@ +name: Release Actions + +# Tags the shared actions in `.github/` with their own `vX.Y.Z` version, so +# other repositories can pin `@ # vX.Y.Z` instead of `# main`. +# A release is only cut when the actions change, not on every push to `main`. + +on: + push: + branches: [main] + paths: + - .github/setup/** + - .github/changeset-preview/** + - .github/comment-on-release/** + - '!**/*.md' + workflow_dispatch: + inputs: + bump: + description: Version bump + type: choice + options: [patch, minor, major] + default: patch + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +permissions: {} + +jobs: + release: + name: Release Actions + if: github.repository_owner == 'TanStack' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: write # creates the release and its tag + steps: + - name: Create Release + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + SHA: ${{ github.sha }} + BUMP: ${{ inputs.bump }} + MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + + # `v1.0.0` and up belong to the actions. The `v0.x` tags are old package releases. + tags=$(gh api "repos/$GH_REPO/git/matching-refs/tags/v" --paginate \ + --jq '.[] | "\(.object.sha) \(.ref | ltrimstr("refs/tags/"))"' | + grep -E ' v[1-9][0-9]*\.[0-9]+\.[0-9]+$' || true) + + if grep -q "^$SHA " <<<"$tags"; then + echo "::notice::$SHA is already released" + exit 0 + fi + + last=$(cut -d ' ' -f 2 <<<"$tags" | sort -V | tail -n 1) + + if [[ -z "$last" ]]; then + next=v1.0.0 + else + if [[ -z "$BUMP" ]]; then + # Pushes take the bump from the conventional commit message. + breaking='^[a-z]+(\([^)]+\))?!:' + if [[ "$MESSAGE" =~ $breaking || "$MESSAGE" == *'BREAKING CHANGE'* ]]; then + BUMP=major + elif [[ "$MESSAGE" == feat* ]]; then + BUMP=minor + else + BUMP=patch + fi + fi + IFS=. read -r major minor patch <<<"${last#v}" + case "$BUMP" in + major) next="v$((major + 1)).0.0" ;; + minor) next="v$major.$((minor + 1)).0" ;; + *) next="v$major.$minor.$((patch + 1))" ;; + esac + fi + + notes="Pin the shared actions to this release: + + \`\`\`yaml + uses: TanStack/config/.github/setup@$SHA # $next + \`\`\`" + if [[ -n "$last" ]]; then + notes+=" + + Changes: https://github.com/$GH_REPO/compare/$last...$next" + fi + + gh release create "$next" --target "$SHA" --title "Actions $next" --notes "$notes" --latest=false diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 3f20b8ac..788c5e29 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -13,6 +13,36 @@ title: CI/CD - Runs tests for code merged into release branches - Runs `nx run-many`, which executes all tasks and ensures the outputs are present (necessary for publishing builds) - Uses [Changesets](https://github.com/changesets/changesets) to handle versioning and publishing +- `release-actions.yml`: + - Runs when a commit on `main` changes one of the shared actions + - Creates a GitHub release that tags them with the next `vX.Y.Z` version + +## Shared Actions + +Other TanStack repositories use three composite actions from this repository: + +- `.github/setup`: sets up Node and pnpm +- `.github/changeset-preview`: comments on a pull request with the versions Changesets would release +- `.github/comment-on-release`: comments on pull requests and linked issues once they are released + +The three actions share one version. Pin them to the commit of a release and put the release tag in the comment: + +```yaml +- name: Setup Tools + uses: TanStack/config/.github/setup@ # v1.0.0 +``` + +Each "Actions vX.Y.Z" [release](https://github.com/TanStack/config/releases) lists the commit to pin. Renovate updates the commit and the comment together when a new release exists. + +Do not put `# main` in the comment. zizmor checks that the ref in the comment still points at the pinned commit, and `main` moves with every package release. + +### Releasing the Actions + +A push to `main` that changes one of the three directories creates the next release. Changes to Markdown files do not count. The commit message decides the version: a breaking change (`!` or `BREAKING CHANGE`) is a major, `feat` is a minor, and anything else is a patch. + +To release by hand, run the "Release Actions" workflow on `main` and choose the bump. + +Release tags are immutable. Do not add a moving `v1` tag: a `# v1` comment would fail zizmor every time the tag moves. ## Nx From 8d2e295b2a5620074c9b730f873c99eae7019ff4 Mon Sep 17 00:00:00 2001 From: Manuel Schiller <6340397+schiller-manuel@users.noreply.github.com> Date: Sun, 29 Nov 2026 18:51:44 +0100 Subject: [PATCH 2/4] ci: let changesets version the shared actions Replace the standalone release workflow with a private `@tanstack/config-actions` package that Changesets versions like the other packages. `release.yml` creates the plain `vX.Y.Z` release for its version, because Renovate does not follow `name@version` tags. Co-Authored-By: Claude Fable 5.2 --- .changeset/config.json | 3 +- .github/package.json | 6 ++ .github/workflows/release-actions.yml | 92 --------------------------- .github/workflows/release.yml | 8 +++ docs/ci-cd.md | 8 +-- pnpm-workspace.yaml | 1 + 6 files changed, 20 insertions(+), 98 deletions(-) create mode 100644 .github/package.json delete mode 100644 .github/workflows/release-actions.yml diff --git a/.changeset/config.json b/.changeset/config.json index 55d4474a..a25c22c5 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -10,5 +10,6 @@ "updateInternalDependencies": "patch", "fixed": [], "linked": [], - "ignore": [] + "ignore": [], + "privatePackages": { "version": true, "tag": false } } diff --git a/.github/package.json b/.github/package.json new file mode 100644 index 00000000..6eec23bd --- /dev/null +++ b/.github/package.json @@ -0,0 +1,6 @@ +{ + "name": "@tanstack/config-actions", + "version": "1.0.0", + "private": true, + "description": "Version of the shared GitHub Actions in this directory." +} diff --git a/.github/workflows/release-actions.yml b/.github/workflows/release-actions.yml deleted file mode 100644 index fd34be85..00000000 --- a/.github/workflows/release-actions.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Release Actions - -# Tags the shared actions in `.github/` with their own `vX.Y.Z` version, so -# other repositories can pin `@ # vX.Y.Z` instead of `# main`. -# A release is only cut when the actions change, not on every push to `main`. - -on: - push: - branches: [main] - paths: - - .github/setup/** - - .github/changeset-preview/** - - .github/comment-on-release/** - - '!**/*.md' - workflow_dispatch: - inputs: - bump: - description: Version bump - type: choice - options: [patch, minor, major] - default: patch - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: false - -permissions: {} - -jobs: - release: - name: Release Actions - if: github.repository_owner == 'TanStack' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - permissions: - contents: write # creates the release and its tag - steps: - - name: Create Release - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - SHA: ${{ github.sha }} - BUMP: ${{ inputs.bump }} - MESSAGE: ${{ github.event.head_commit.message }} - run: | - set -euo pipefail - - # `v1.0.0` and up belong to the actions. The `v0.x` tags are old package releases. - tags=$(gh api "repos/$GH_REPO/git/matching-refs/tags/v" --paginate \ - --jq '.[] | "\(.object.sha) \(.ref | ltrimstr("refs/tags/"))"' | - grep -E ' v[1-9][0-9]*\.[0-9]+\.[0-9]+$' || true) - - if grep -q "^$SHA " <<<"$tags"; then - echo "::notice::$SHA is already released" - exit 0 - fi - - last=$(cut -d ' ' -f 2 <<<"$tags" | sort -V | tail -n 1) - - if [[ -z "$last" ]]; then - next=v1.0.0 - else - if [[ -z "$BUMP" ]]; then - # Pushes take the bump from the conventional commit message. - breaking='^[a-z]+(\([^)]+\))?!:' - if [[ "$MESSAGE" =~ $breaking || "$MESSAGE" == *'BREAKING CHANGE'* ]]; then - BUMP=major - elif [[ "$MESSAGE" == feat* ]]; then - BUMP=minor - else - BUMP=patch - fi - fi - IFS=. read -r major minor patch <<<"${last#v}" - case "$BUMP" in - major) next="v$((major + 1)).0.0" ;; - minor) next="v$major.$((minor + 1)).0" ;; - *) next="v$major.$minor.$((patch + 1))" ;; - esac - fi - - notes="Pin the shared actions to this release: - - \`\`\`yaml - uses: TanStack/config/.github/setup@$SHA # $next - \`\`\`" - if [[ -n "$last" ]]; then - notes+=" - - Changes: https://github.com/$GH_REPO/compare/$last...$next" - fi - - gh release create "$next" --target "$SHA" --title "Actions $next" --notes "$notes" --latest=false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a4709da..83a2ded7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,3 +50,11 @@ jobs: uses: $/.github/comment-on-release with: published-packages: ${{ steps.changesets.outputs.published-packages }} + - name: Release Actions + if: github.ref == 'refs/heads/main' + env: + GH_TOKEN: ${{ github.token }} + run: | + tag="v$(jq -r .version .github/package.json)" + gh release view "$tag" > /dev/null 2>&1 || + gh release create "$tag" --target "$GITHUB_SHA" --title "Actions $tag" --notes "Pin the actions as @$GITHUB_SHA # $tag" --latest=false diff --git a/docs/ci-cd.md b/docs/ci-cd.md index 788c5e29..eb0c5249 100644 --- a/docs/ci-cd.md +++ b/docs/ci-cd.md @@ -13,9 +13,7 @@ title: CI/CD - Runs tests for code merged into release branches - Runs `nx run-many`, which executes all tasks and ensures the outputs are present (necessary for publishing builds) - Uses [Changesets](https://github.com/changesets/changesets) to handle versioning and publishing -- `release-actions.yml`: - - Runs when a commit on `main` changes one of the shared actions - - Creates a GitHub release that tags them with the next `vX.Y.Z` version + - Creates a `vX.Y.Z` release for the shared actions when their version changes ## Shared Actions @@ -38,9 +36,9 @@ Do not put `# main` in the comment. zizmor checks that the ref in the comment st ### Releasing the Actions -A push to `main` that changes one of the three directories creates the next release. Changes to Markdown files do not count. The commit message decides the version: a breaking change (`!` or `BREAKING CHANGE`) is a major, `feat` is a minor, and anything else is a patch. +Changesets versions the actions as the private package `@tanstack/config-actions` in `.github/package.json`. When you change an action, add a changeset for that package. After the "Version Packages" pull request is merged, `release.yml` creates the `vX.Y.Z` release for the new version. -To release by hand, run the "Release Actions" workflow on `main` and choose the bump. +Changesets would tag the package as `@tanstack/config-actions@X.Y.Z`, and Renovate does not read that as a version. The workflow creates the plain `vX.Y.Z` tag for that reason. Release tags are immutable. Do not add a moving `v1` tag: a `# v1` comment would fail zizmor every time the tag moves. diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 3a344f78..5ac87cef 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,6 +3,7 @@ linkWorkspacePackages: true preferWorkspacePackages: true packages: + - .github - integrations/* - packages/* From 06b9999ef45c4af4873be4b0ac68275442316c0e Mon Sep 17 00:00:00 2001 From: Manuel Schiller <6340397+schiller-manuel@users.noreply.github.com> Date: Sun, 29 Nov 2026 20:54:29 +0100 Subject: [PATCH 3/4] ci: read the actions version from the pushed commit The changesets action runs the version script in the checkout before it opens the version PR, so the working tree can hold a version that is not merged yet. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 83a2ded7..6965702b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - tag="v$(jq -r .version .github/package.json)" + # Changesets may have bumped the checked out file for the version PR. + tag="v$(git show "$GITHUB_SHA:.github/package.json" | jq -r .version)" gh release view "$tag" > /dev/null 2>&1 || gh release create "$tag" --target "$GITHUB_SHA" --title "Actions $tag" --notes "Pin the actions as @$GITHUB_SHA # $tag" --latest=false From 8b37a00a798b5a391fd6fcdef6403c58a1969686 Mon Sep 17 00:00:00 2001 From: Manuel Schiller <6340397+schiller-manuel@users.noreply.github.com> Date: Sun, 29 Nov 2026 21:00:14 +0100 Subject: [PATCH 4/4] ci: release the commit that set the actions version A later push to main can cancel the run of the version commit. The next run then created the release at its own commit, which may hold action changes that are not part of that version. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6965702b..7edacdf3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,9 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - # Changesets may have bumped the checked out file for the version PR. - tag="v$(git show "$GITHUB_SHA:.github/package.json" | jq -r .version)" + # Release the commit on main that set the version. The checkout may + # hold a version that Changesets bumped for the version PR. + sha="$(git log -1 --format=%H "$GITHUB_SHA" -- .github/package.json)" + tag="v$(git show "$sha:.github/package.json" | jq -r .version)" gh release view "$tag" > /dev/null 2>&1 || - gh release create "$tag" --target "$GITHUB_SHA" --title "Actions $tag" --notes "Pin the actions as @$GITHUB_SHA # $tag" --latest=false + gh release create "$tag" --target "$sha" --title "Actions $tag" --notes "Pin the actions as @$sha # $tag" --latest=false