Open History to see the last commit
1name: Release
2
3on:
4 push:
5 branches: [main, alpha, beta, rc, 'v[0-9]', '*-pre', '*-maint']
6
7concurrency:
8 group: ${{ github.workflow }}-${{ github.ref }}
9 cancel-in-progress: false
10
11env:
12 NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
13
14permissions:
15 contents: read
16
17jobs:
18 release:
19 name: Release
20 if: ${{ github.repository_owner == 'TanStack' }}
21 runs-on: ubuntu-latest
22 permissions:
23 contents: write
24 id-token: write
25 pull-requests: write
26 outputs:
27 published: ${{ steps.changesets.outputs.published }}
28 packages: ${{ steps.changesets.outputs.publishedPackages }}
29 prerelease: ${{ steps.dist-tag.outputs.prerelease }}
30 latest: ${{ steps.dist-tag.outputs.latest }}
31 steps:
32 - name: Checkout
33 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34 with:
35 fetch-depth: 0
36 persist-credentials: true # changesets/action pushes version PR commits
37 - name: Setup Tools
38 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main
39 - name: Build
40 run: pnpm build
41 - name: Test Unit
42 run: pnpm test:unit
43 - name: Install Playwright Chrome
44 run: pnpm --filter @tanstack/cli exec playwright install --with-deps chrome
45 - name: E2E Blocking
46 run: pnpm --filter @tanstack/cli test:e2e
47
48 - name: Enter Pre-Release Mode
49 if: "(contains(github.ref_name, '-pre') || github.ref_name == 'alpha' || github.ref_name == 'beta' || github.ref_name == 'rc') && !hashFiles('.changeset/pre.json')"
50 run: |
51 BRANCH="${GITHUB_REF_NAME}"
52 if [[ "$BRANCH" == "alpha" || "$BRANCH" == "beta" || "$BRANCH" == "rc" ]]; then
53 pnpm changeset pre enter "$BRANCH"
54 else
55 pnpm changeset pre enter pre
56 fi
57 - name: Determine dist-tag
58 id: dist-tag
59 run: |
60 BRANCH="${GITHUB_REF_NAME}"
61 if [[ "$BRANCH" == "alpha" || "$BRANCH" == "beta" || "$BRANCH" == "rc" ]]; then
62 echo "prerelease=true" >> "$GITHUB_OUTPUT"
63 echo "tag=$BRANCH" >> "$GITHUB_OUTPUT"
64 elif [[ "$BRANCH" == *-pre ]]; then
65 echo "prerelease=true" >> "$GITHUB_OUTPUT"
66 echo "tag=pre" >> "$GITHUB_OUTPUT"
67 elif [[ "$BRANCH" == *-maint ]]; then
68 echo "tag=maint" >> "$GITHUB_OUTPUT"
69 elif [[ "$BRANCH" =~ ^v[0-9]+$ ]]; then
70 echo "tag=$BRANCH" >> "$GITHUB_OUTPUT"
71 else
72 echo "latest=true" >> "$GITHUB_OUTPUT"
73 fi
74
75 - name: Create Release Pull Request or Publish
76 id: changesets
77 uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
78 with:
79 version: pnpm run changeset:version
80 publish: pnpm run changeset:publish ${{ steps.dist-tag.outputs.tag && format('--tag {0}', steps.dist-tag.outputs.tag) }}
81 title: 'ci: Version Packages'
82 commit: 'ci: changeset release'
83 env:
84 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85 verify-release:
86 name: Verify Published Release
87 needs: release
88 if: needs.release.outputs.published == 'true'
89 runs-on: ubuntu-latest
90 permissions:
91 contents: write
92 steps:
93 - name: Checkout
94 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
95 with:
96 fetch-depth: 0
97 persist-credentials: false
98 - name: Setup Node
99 uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
100 with:
101 node-version: 24
102 - name: Verify Package Availability and Integrity
103 run: node scripts/verify-release-artifacts.mjs
104 env:
105 PUBLISHED_PACKAGES: ${{ needs.release.outputs.packages }}
106 - name: Create GitHub Release
107 run: |
108 gh auth setup-git
109 git config user.name "github-actions[bot]"
110 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
111 node scripts/create-github-release.mjs ${PRERELEASE_FLAG} ${LATEST_FLAG}
112 env:
113 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115 PRERELEASE_FLAG: ${{ needs.release.outputs.prerelease == 'true' && '--prerelease' }}
116 LATEST_FLAG: ${{ needs.release.outputs.latest == 'true' && '--latest' }}