-
Notifications
You must be signed in to change notification settings - Fork 2
189 lines (159 loc) · 5.4 KB
/
release.yml
File metadata and controls
189 lines (159 loc) · 5.4 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
release_type:
description: "Release type"
required: true
type: choice
default: "snapshot"
options:
- "stable"
- "snapshot"
packages:
description: "Packages to publish (snapshots only)"
required: false
type: choice
default: "@nylas/react"
options:
- "@nylas/connect"
- "@nylas/react"
snapshot_tag:
description: "Snapshot tag (snapshots only)"
required: false
default: "canary"
type: choice
options:
- "canary"
- "alpha"
- "beta"
- "snapshot"
- "dev"
run-name: >-
${{ inputs.release_type == 'snapshot'
&& format('Snapshot: {0}@{1} by @{2}', inputs.packages, inputs.snapshot_tag, github.actor)
|| 'Release' }}
# Prevent multiple releases from running at the same time
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
NODE_VERSION: ${{ vars.NODE_VERSION }}
jobs:
release:
name: Release
if: inputs.release_type != 'snapshot'
runs-on: ubuntu-latest
permissions:
contents: write # to create release commits and tags
pull-requests: write # to create release PRs
id-token: write # for NPM provenance
timeout-minutes: 15
outputs:
published: ${{ steps.changesets.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SDK_RELEASE_PAT }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
- name: Update npm
run: npm install -g npm@latest
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm typecheck
- name: Check formatting
run: pnpm format:check
- name: Build packages
run: pnpm build
- name: Run tests
run: pnpm test
- name: Run tests with coverage
run: pnpm --filter @nylas/connect coverage
- name: Create Release Pull Request or Publish to NPM
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version
publish: pnpm run publish
title: "chore: version packages"
commit: "chore: version packages"
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.SDK_RELEASE_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # do not remove this line (https://github.com/changesets/action/issues/98)
NPM_CONFIG_PROVENANCE: true
snapshot:
name: Publish Snapshot
if: inputs.release_type == 'snapshot'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # for NPM provenance
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create snapshot version
run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build packages
run: pnpm nx run-many -t build --parallel=3 --projects=${{ inputs.packages }}
- name: Publish snapshot
run: |
pnpm changeset publish --no-git-tag --snapshot --tag ${{ inputs.snapshot_tag }} | tee /tmp/changeset_publish.log
echo '### Published Snapshot Packages' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
grep -oP '@nylas/\S+' /tmp/changeset_publish.log | grep '@[0-9]' | sort -u | \
sed 's/^/- /' >> $GITHUB_STEP_SUMMARY || echo '- No packages published' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '<details><summary>Full publish log</summary>' >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat /tmp/changeset_publish.log >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '</details>' >> $GITHUB_STEP_SUMMARY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true