99 push :
1010 branches :
1111 - main
12+ pull_request :
13+ types : [labeled]
1214
1315jobs :
1416 release :
1517 runs-on : ubuntu-latest
16- if : startsWith(github.event.head_commit.message, 'chore(release):')
18+ if : github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')
1719 steps :
1820 - name : Checkout Code
1921 uses : actions/checkout@v4
4850 - name : Install Dependencies
4951 if : steps.version.outputs.version != ''
5052 run : bun install --frozen-lockfile
51- env :
52- BTS_TELEMETRY : 0
53-
54- - name : Build CLI
55- if : steps.version.outputs.version != ''
56- run : cd apps/cli && bun run build
57- env :
58- BTS_TELEMETRY : 0
5953
6054 - name : Create GitHub Release
6155 if : steps.version.outputs.version != ''
6963 env :
7064 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7165
66+ - name : Update types package version
67+ if : steps.version.outputs.version != ''
68+ run : |
69+ VERSION=${{ steps.version.outputs.version }}
70+ cd packages/types
71+ bun run node -e "const pkg=require('./package.json');pkg.version='$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2)+'\n')"
72+
73+ - name : Build types package
74+ if : steps.version.outputs.version != ''
75+ run : cd packages/types && bun run build
76+
77+ - name : Publish types to NPM
78+ if : steps.version.outputs.version != ''
79+ run : cd packages/types && bun publish --access public
80+ env :
81+ NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
82+ BTS_TELEMETRY : 1
83+
84+ - name : Update CLI types dependency
85+ if : steps.version.outputs.version != ''
86+ run : |
87+ VERSION=${{ steps.version.outputs.version }}
88+ cd apps/cli
89+ bun run node -e "const pkg=require('./package.json');pkg.dependencies['@better-t-stack/types']='^$VERSION';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2)+'\n')"
90+
91+ - name : Build CLI
92+ if : steps.version.outputs.version != ''
93+ run : cd apps/cli && bun run build
94+ env :
95+ BTS_TELEMETRY : 1
96+
7297 - name : Update create-bts alias package version
7398 if : steps.version.outputs.version != ''
7499 run : |
@@ -89,3 +114,117 @@ jobs:
89114 env :
90115 NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
91116 BTS_TELEMETRY : 1
117+
118+ canary :
119+ runs-on : ubuntu-latest
120+ if : github.event_name == 'pull_request' && github.event.label.name == 'canary'
121+ steps :
122+ - name : Checkout Code
123+ uses : actions/checkout@v4
124+ with :
125+ fetch-depth : 0
126+ ref : ${{ github.event.pull_request.head.sha }}
127+
128+ - name : Setup Bun
129+ uses : oven-sh/setup-bun@v2
130+ with :
131+ bun-version : latest
132+
133+ - name : Install Dependencies
134+ run : bun install --frozen-lockfile
135+ env :
136+ BTS_TELEMETRY : 0
137+
138+ - name : Get canary version
139+ id : canary
140+ run : |
141+ COMMIT_HASH=$(git rev-parse --short HEAD)
142+ BASE_VERSION=$(jq -r '.version' apps/cli/package.json | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
143+ CANARY_VERSION="${BASE_VERSION}-canary.${COMMIT_HASH}"
144+ echo "version=$CANARY_VERSION" >> $GITHUB_OUTPUT
145+ echo "commit=$COMMIT_HASH" >> $GITHUB_OUTPUT
146+
147+ - name : Update types package version
148+ run : |
149+ cd packages/types
150+ jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v' package.json > tmp.json && mv tmp.json package.json
151+
152+ - name : Build types package
153+ run : cd packages/types && bun run build
154+
155+ - name : Publish types canary to NPM
156+ run : cd packages/types && bun publish --access public --tag canary
157+ env :
158+ NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
159+ BTS_TELEMETRY : 0
160+
161+ - name : Update CLI package version and types dependency
162+ run : |
163+ cd apps/cli
164+ jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v | .dependencies["@better-t-stack/types"] = $v' package.json > tmp.json && mv tmp.json package.json
165+
166+ - name : Update create-bts alias package version
167+ run : |
168+ cd packages/create-bts
169+ jq --arg v "${{ steps.canary.outputs.version }}" '.version = $v | .dependencies["create-better-t-stack"] = $v' package.json > tmp.json && mv tmp.json package.json
170+
171+ - name : Build CLI
172+ run : cd apps/cli && bun run build
173+ env :
174+ BTS_TELEMETRY : 0
175+
176+ - name : Publish CLI canary to NPM
177+ run : cd apps/cli && bun publish --access public --tag canary
178+ env :
179+ NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
180+ BTS_TELEMETRY : 0
181+
182+ - name : Publish create-bts canary to NPM
183+ run : cd packages/create-bts && bun publish --access public --tag canary
184+ env :
185+ NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
186+ BTS_TELEMETRY : 0
187+
188+ - name : Find existing canary comment
189+ uses : peter-evans/find-comment@v3
190+ id : find-comment
191+ with :
192+ issue-number : ${{ github.event.pull_request.number }}
193+ comment-author : " github-actions[bot]"
194+ body-includes : " Canary Release"
195+
196+ - name : Create or update PR comment
197+ uses : peter-evans/create-or-update-comment@v4
198+ with :
199+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
200+ issue-number : ${{ github.event.pull_request.number }}
201+ edit-mode : replace
202+ body : |
203+ ## Canary Release
204+
205+ A canary version has been published for this PR.
206+
207+ **Version:** `${{ steps.canary.outputs.version }}`
208+ **Commit:** `${{ steps.canary.outputs.commit }}`
209+
210+ ### Try it out
211+
212+ ```bash
213+ # Using bun
214+ bun create better-t-stack@${{ steps.canary.outputs.version }} my-app
215+
216+ # Using npx
217+ npx create-better-t-stack@${{ steps.canary.outputs.version }} my-app
218+
219+ # Using the alias
220+ bun create bts@${{ steps.canary.outputs.version }} my-app
221+ npx create-bts@${{ steps.canary.outputs.version }} my-app
222+ ```
223+
224+ ### NPM Links
225+ - [create-better-t-stack@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/create-better-t-stack/v/${{ steps.canary.outputs.version }})
226+ - [create-bts@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/create-bts/v/${{ steps.canary.outputs.version }})
227+ - [@better-t-stack/types@${{ steps.canary.outputs.version }}](https://www.npmjs.com/package/@better-t-stack/types/v/${{ steps.canary.outputs.version }})
228+
229+ ---
230+ *To publish a new canary after more commits, remove and re-add the `canary` label.*
0 commit comments