Open History to see the last commit
1name: Release
2
3on:
4 push:
5 branches: [main, alpha, beta]
6
7concurrency:
8 group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
9 cancel-in-progress: true
10
11env:
12 NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
13
14permissions:
15 contents: write
16 id-token: write
17 issues: write
18 pull-requests: write
19
20jobs:
21 release:
22 name: Release
23 if: github.repository_owner == 'TanStack'
24 runs-on: ubuntu-latest
25 steps:
26 - name: Checkout
27 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28 with:
29 fetch-depth: 0
30 persist-credentials: true # release job pushes version/docs changes
31 - name: Setup Tools
32 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
33 - name: Check lint
34 run: pnpm run lint:check
35 - name: Build packages
36 run: pnpm run build
37 - name: Run Tests
38 run: pnpm run test
39 - name: Run Changesets (version or publish)
40 id: changesets
41 uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
42 with:
43 version: pnpm run changeset:version
44 publish: pnpm run changeset:publish
45 commit: 'ci: Version Packages'
46 title: 'ci: Version Packages'
47 env:
48 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 - name: Generate Docs
50 if: steps.changesets.outputs.published == 'true'
51 run: pnpm generate-docs
52 - name: Commit Generated Docs
53 if: steps.changesets.outputs.published == 'true'
54 run: |
55 if [ -n "$(git status --porcelain)" ]; then
56 git config user.name "github-actions[bot]"
57 git config user.email "github-actions[bot]@users.noreply.github.com"
58
59 EXISTING_BRANCH=$(gh pr list --author "app/github-actions" --search "docs: regenerate API documentation in:title" --state open --json headRefName --jq '.[0].headRefName' 2>/dev/null || echo "")
60 CREATE_PR=true
61
62 if [ -n "$EXISTING_BRANCH" ] && [ "$EXISTING_BRANCH" != "null" ]; then
63 BRANCH="$EXISTING_BRANCH"
64 echo "Found existing docs PR on branch $BRANCH, updating it"
65 git checkout -B "$BRANCH"
66 CREATE_PR=false
67 else
68 BRANCH="docs/auto-update-$(date +%s)"
69 git checkout -b "$BRANCH"
70 fi
71
72 git add docs/
73 if git diff --cached --quiet; then
74 echo "No new docs changes to commit"
75 exit 0
76 fi
77 git commit -m "docs: regenerate API documentation"
78 git push --force-with-lease origin "$BRANCH"
79
80 if [ "$CREATE_PR" = true ]; then
81 gh pr create \
82 --title "docs: regenerate API documentation" \
83 --body "Automated documentation update from release" \
84 --base main \
85 --head "$BRANCH"
86 fi
87 else
88 echo "No changes in generated docs"
89 fi
90 env:
91 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92 - name: Comment on PRs about release
93 if: steps.changesets.outputs.published == 'true'
94 uses: tanstack/config/.github/comment-on-release@e4b48f16568324f76f467aa4c2aac2f05db632c3
95 with:
96 published-packages: ${{ steps.changesets.outputs.publishedPackages }}
97 env:
98 # The pinned action reads REPOSITORY but does not set it.
99 REPOSITORY: ${{ github.repository }}