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 pull-requests: write
18
19jobs:
20 release:
21 name: Release
22 if: github.repository_owner == 'TanStack'
23 runs-on: ubuntu-latest
24 steps:
25 - name: Checkout
26 uses: actions/checkout@v6.0.1
27 with:
28 fetch-depth: 0
29 - name: Setup Tools
30 uses: tanstack/config/.github/setup@main
31 - name: Run Tests
32 run: pnpm run lint && pnpm run build && pnpm run test
33 - name: Run Changesets (version or publish)
34 id: changesets
35 uses: changesets/action@v1.5.3
36 with:
37 version: pnpm run changeset:version
38 publish: pnpm run changeset:publish
39 commit: 'ci: Version Packages'
40 title: 'ci: Version Packages'
41 env:
42 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 - name: Generate Docs
44 if: steps.changesets.outputs.published == 'true'
45 run: pnpm generate-docs
46 - name: Commit Generated Docs
47 if: steps.changesets.outputs.published == 'true'
48 run: |
49 if [ -n "$(git status --porcelain)" ]; then
50 git config user.name "github-actions[bot]"
51 git config user.email "github-actions[bot]@users.noreply.github.com"
52
53 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 "")
54 CREATE_PR=true
55
56 if [ -n "$EXISTING_BRANCH" ] && [ "$EXISTING_BRANCH" != "null" ]; then
57 BRANCH="$EXISTING_BRANCH"
58 echo "Found existing docs PR on branch $BRANCH, updating it"
59 git checkout -B "$BRANCH"
60 CREATE_PR=false
61 else
62 BRANCH="docs/auto-update-$(date +%s)"
63 git checkout -b "$BRANCH"
64 fi
65
66 git add docs/
67 if git diff --cached --quiet; then
68 echo "No new docs changes to commit"
69 exit 0
70 fi
71 git commit -m "docs: regenerate API documentation"
72 git push --force-with-lease origin "$BRANCH"
73
74 if [ "$CREATE_PR" = true ]; then
75 gh pr create \
76 --title "docs: regenerate API documentation" \
77 --body "Automated documentation update from release" \
78 --base main \
79 --head "$BRANCH"
80 fi
81 else
82 echo "No changes in generated docs"
83 fi
84 env:
85 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86 - name: Comment on PRs about release
87 if: steps.changesets.outputs.published == 'true'
88 uses: tanstack/config/.github/comment-on-release@main
89 with:
90 published-packages: ${{ steps.changesets.outputs.publishedPackages }}