-
-
Notifications
You must be signed in to change notification settings - Fork 104
203 lines (173 loc) · 7.9 KB
/
ci.yml
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
NODE_OPTIONS: --max_old_space_size=4096
jobs:
build:
name: 🏗️ Build
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
published: ${{ steps.changesets.outputs.published }}
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
deployments: write # to create deployments (cloudflare/pages)
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- name: 🔧 Setup
uses: ./.github/actions/setup
- name: 🩺 Check
run: pnpm check
- name: 🤘 Test
run: pnpm test:coverage
- name: 📖 Coveralls
continue-on-error: true
# prevents this step from running on forks
if: ${{ github.repository == 'tw-in-js/twind' }}
# until https://github.com/coverallsapp/github-action/issues/135 is closed
uses: chenrui333/github-action@a1a1a8a300a7e89df3630639df8fb23de5cc6368
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
- name: 🚚 Create Release PR or Publish to npm
id: changesets
if: ${{ github.repository == 'tw-in-js/twind' && github.event_name == 'push' }}
uses: changesets/action@v1
with:
version: pnpm changeset:version
publish: pnpm changeset:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# wait a bit and then set latest for twind back to v0.16
# because some are using CDNs without specifing a version
- name: 📝 Keep latest tag on twind@v0.16.19
if: steps.changesets.outputs.published == 'true'
run: |
sleep 20
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
npm dist-tag add twind@0.16.19 latest || true
npm deprecate twind@1.x "use @twind/core instead" || true
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 🌎 Deploy twind.style
if: ${{ steps.changesets.outputs.published == 'true' && github.repository == 'tw-in-js/twind' }}
uses: ./.github/actions/publish-pages
with:
workingDirectory: sites/twind.style
directory: build
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDLFARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploymentName: twind.style
projectName: twind-style
branch: main
- name: 🌎 Deploy twind.run
if: ${{ steps.changesets.outputs.published == 'true' && github.repository == 'tw-in-js/twind' }}
uses: ./.github/actions/publish-pages
with:
workingDirectory: sites/twind.run
directory: .svelte-kit/cloudflare
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDLFARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploymentName: twind.run
projectName: twind-run
branch: main
publish-pre-releases:
name: 🚚 Publish pre-releases
needs: build
runs-on: ubuntu-latest
timeout-minutes: 60
if: ${{ needs.build.outputs.published != 'true' }}
permissions:
contents: read
pull-requests: write
deployments: write
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: 🔧 Setup
uses: ./.github/actions/setup
with:
# only install dependencies for packages that are published and for the sites
installArgs: --filter="." --filter="./packages/*" --filter="./sites/*"
- name: 🚚 Publish pre-release to npm
id: publish
uses: ./.github/actions/publish-prerelease
with:
tag: ${{ (github.event_name == 'push' && 'next') || 'canary'}}
template: ${{ (github.event_name == 'push' && '{tag}-{datetime}') || '{tag}-{commit}'}}
hasChangesets: ${{ needs.build.outputs.hasChangesets }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# deploy sites using the published package versions
- name: 🌎 Deploy twind.style
id: deploy_twind_style
uses: ./.github/actions/publish-pages
with:
workingDirectory: sites/twind.style
directory: build
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDLFARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
# no github deployment for canary
GITHUB_TOKEN: ${{ (github.event.number && '') || secrets.GITHUB_TOKEN }}
deploymentName: twind.style
projectName: twind-style
branch: ${{ (github.event.number && format('pr-{0}', github.event.number)) || (github.event_name == 'push' && 'next') || 'canary' }}
- name: 🌎 Deploy twind.run
id: deploy_twind_run
uses: ./.github/actions/publish-pages
with:
workingDirectory: sites/twind.run
directory: .svelte-kit/cloudflare
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDLFARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
# no github deployment for canary
GITHUB_TOKEN: ${{ (github.event.number && '') || secrets.GITHUB_TOKEN }}
deploymentName: twind.run
projectName: twind-run
branch: ${{ (github.event.number && format('pr-{0}', github.event.number)) || (github.event_name == 'push' && 'next') || 'canary' }}
- name: 📝 Comment PR
if: ${{ github.event.number }}
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: '## Deployed site previews with [![Cloudflare Pages]'
message: |
> **Latest commit**: ${{ github.sha }}
## Deployed site previews with [![Cloudflare Pages](https://img.shields.io/badge/Cloudflare%20Pages-F38020?style=for-the-badge&logo=Cloudflare&logoColor=white)](https://pages.dev)
### twind.style
<table>
<tr><td><strong>Deployment URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.url }}'>${{ steps.deploy_twind_style.outputs.url }}</a></td></tr>
<tr><td><strong>Branch URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.branch }}'>${{ steps.deploy_twind_style.outputs.branch }}</a></td></tr>
<tr><td><strong>Version URL:</strong></td><td><a href='${{ steps.deploy_twind_style.outputs.version }}'>${{ steps.deploy_twind_style.outputs.version }}</a></td></tr>
</table>
### twind.run
<table>
<tr><td><strong>Deployment URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.url }}'>${{ steps.deploy_twind_run.outputs.url }}</a></td></tr>
<tr><td><strong>Branch URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.branch }}'>${{ steps.deploy_twind_run.outputs.branch }}</a></td></tr>
<tr><td><strong>Version URL:</strong></td><td><a href='${{ steps.deploy_twind_run.outputs.version }}'>${{ steps.deploy_twind_run.outputs.version }}</a></td></tr>
</table>
## Published to [npm](https://www.npmjs.com)
**Dist Tag**: ${{ steps.publish.output.tag }}
**Packages**:
${{ steps.publish.output.packages }}