-
Notifications
You must be signed in to change notification settings - Fork 313
94 lines (79 loc) · 2.96 KB
/
release-canary.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Release - Canary
on:
pull_request:
types: [labeled]
branches:
- main
jobs:
release:
if: contains(github.event.pull_request.labels.*.name, 'release canary')
name: Build & Publish a canary release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use PNPM
uses: pnpm/[email protected]
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install deps (with cache)
run: pnpm install
- name: Check packages for common errors
run: pnpm turbo --filter "./packages/*" build
- name: Bump version to canary
run: node .github/canary-version.js
- name: Authenticate to npm and publish
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
for dir in packages/*/; do
if [ "$dir" != "packages/config/" ]; then
pnpm publish "$dir" --access public --tag canary --no-git-checks
fi
done
- name: Create a new comment notifying of the new canary version
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Get package version
const fs = require("fs");
let text = 'A new canary is available for testing. You can install this latest build in your project with:\n\n```sh\n'
const pkgJsonPaths = fs
.readdirSync("packages")
.filter((dir) => dir !== "config")
.map((dir) => `packages/${dir}/package.json`);
for (const pkgJsonPath of pkgJsonPaths) {
const packageJson = JSON.parse(fs.readFileSync(pkgJsonPath));
const version = packageJson.version;
text += `pnpm add ${packageJson.name}@${version}\n`
}
text += '```\n\n'
// Create a comment on the PR with the new canary version
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: text,
})
// Remove the label
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: 'release canary',
});