Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

release.yml

116 lines4.0 KB

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: read
16​
17jobs:
18 lint:
19 name: Lint
20 if: github.repository_owner == 'TanStack'
21 runs-on: ubuntu-latest
22 steps:
23 - name: Checkout
24 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25 with:
26 persist-credentials: false
27 - name: Setup Tools
28 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
29 - name: Check lint
30 run: pnpm run lint:check
31 - name: Check release versioning
32 run: pnpm run test:release
33​
34 # Temporarily rely on PR test jobs during the staged RC publication.
35 # Restore the release test matrices and DB report merge after npm bootstrap.
36 release:
37 name: Release
38 needs: [lint]
39 if: github.repository_owner == 'TanStack'
40 runs-on: ubuntu-latest
41 permissions:
42 contents: write
43 id-token: write
44 issues: write
45 pull-requests: write
46 steps:
47 - name: Checkout
48 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49 with:
50 fetch-depth: 0
51 persist-credentials: true # release job pushes version/docs changes
52 - name: Setup Tools
53 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
54 - name: Build packages
55 run: pnpm run build
56 - name: Run Changesets (version or publish)
57 id: changesets
58 uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3
59 with:
60 version: pnpm run changeset:version
61 publish: pnpm run changeset:publish
62 commit: 'ci: Version Packages'
63 title: 'ci: Version Packages'
64 env:
65 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 - name: Generate Docs
67 if: steps.changesets.outputs.published == 'true'
68 run: pnpm generate-docs
69 - name: Commit Generated Docs
70 if: steps.changesets.outputs.published == 'true'
71 run: |
72 if [ -n "$(git status --porcelain)" ]; then
73 git config user.name "github-actions[bot]"
74 git config user.email "github-actions[bot]@users.noreply.github.com"
75​
76 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 "")
77 CREATE_PR=true
78​
79 if [ -n "$EXISTING_BRANCH" ] && [ "$EXISTING_BRANCH" != "null" ]; then
80 BRANCH="$EXISTING_BRANCH"
81 echo "Found existing docs PR on branch $BRANCH, updating it"
82 git checkout -B "$BRANCH"
83 CREATE_PR=false
84 else
85 BRANCH="docs/auto-update-$(date +%s)"
86 git checkout -b "$BRANCH"
87 fi
88​
89 git add docs/
90 if git diff --cached --quiet; then
91 echo "No new docs changes to commit"
92 exit 0
93 fi
94 git commit -m "docs: regenerate API documentation"
95 git push --force-with-lease origin "$BRANCH"
96​
97 if [ "$CREATE_PR" = true ]; then
98 gh pr create \
99 --title "docs: regenerate API documentation" \
100 --body "Automated documentation update from release" \
101 --base main \
102 --head "$BRANCH"
103 fi
104 else
105 echo "No changes in generated docs"
106 fi
107 env:
108 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109 - name: Comment on PRs about release
110 if: steps.changesets.outputs.published == 'true'
111 uses: tanstack/config/.github/comment-on-release@e4b48f16568324f76f467aa4c2aac2f05db632c3
112 with:
113 published-packages: ${{ steps.changesets.outputs.publishedPackages }}
114 env:
115 # The pinned action reads REPOSITORY but does not set it.
116 REPOSITORY: ${{ github.repository }}