-
Notifications
You must be signed in to change notification settings - Fork 11
200 lines (172 loc) · 6.59 KB
/
main.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
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
name: Main
on:
workflow_dispatch:
inputs:
releaseType:
description: "Release Type"
required: true
default: "prerelease"
type: choice
options:
- major
- minor
- patch
- prerelease
push:
branches:
- "main"
tags-ignore:
- "*"
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
RELEASE_TYPE: ${{ github.event_name == 'push' && 'prerelease' || github.event.inputs.releaseType }}
# This can only be triggered from main
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.GH_ACTIONS_DEPLOY_KEY_RULE_BYPASS }}
- uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".tool-versions"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- run: pnpm install nx --global
- run: pnpm run lint:ci
- run: pnpm run format:ci
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "Zudoku Bot"
- name: Version Bump (Zudoku)
run: pnpm version ${{ env.RELEASE_TYPE }} --preid dev
working-directory: packages/zudoku
- name: Version Bump (Create App)
run: pnpm version ${{ env.RELEASE_TYPE }} --preid dev
working-directory: packages/create-zudoku-app
# Build must happen after version bump so builds use the correct version
- run: nx run-many -t build:ci
- run: git add -A
- run: echo "ZUDOKU_VERSION=$(node -e 'console.log(require(`./packages/zudoku/package.json`).version)')" >> $GITHUB_ENV
# Push changes before publishing because if it fails we still want the tag
- name: Commit & Push Changes
run: |
git commit -m "[Version] ${{ env.ZUDOKU_VERSION }} [skip ci]" --no-verify
git tag ${{ env.ZUDOKU_VERSION }}
git push origin main --tags
- name: Publish Module (Zudoku)
run: pnpm publish --provenance --filter zudoku --tag ${{ env.RELEASE_TYPE == 'prerelease' && 'dev' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Publish Module (Create App)
run: pnpm publish --provenance --filter create-zudoku-app --tag ${{ env.RELEASE_TYPE == 'prerelease' && 'dev' || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
with:
token_format: "access_token"
workload_identity_provider: ${{ vars.GCP_ACTIONS_IDENTITY_PROVIDER }}
service_account: github-actions-opensource@zuplo-production.iam.gserviceaccount.com
access_token_lifetime: "300s"
- name: Upload CSS
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.css"
destination: cdn.zudoku.dev/${{ env.ZUDOKU_VERSION }}
parent: false
headers: |-
content-type: text/css
- name: Upload Javascript
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.js"
destination: cdn.zudoku.dev/${{ env.ZUDOKU_VERSION }}
parent: false
headers: |-
content-type: text/javascript
- name: Upload HTML (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone/index.html
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/html
- name: Upload CSS (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.css"
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/css
- name: Upload Javascript (Latest)
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/standalone
glob: "**/*.js"
destination: cdn.zudoku.dev/latest
parent: false
headers: |-
content-type: text/javascript
- name: Upload Artifacts
uses: "google-github-actions/upload-cloud-storage@v2"
with:
process_gcloudignore: false
path: packages/zudoku/stats.html
destination: cdn.zudoku.dev/build/rollup/${{ github.run_id }}-${{ github.run_attempt }}
parent: false
headers: |-
content-type: text/html
- name: Clear CDN Cache
run: |
curl --request POST \
--url https://api.cloudflare.com/client/v4/zones/1abaefabd6800e9979a740a7cdf235a8/purge_cache \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${{ secrets.CF_ZONE_PURGE_ACCESS_TOKEN }}' \
--data '{
"files": [
"https://cdn.zudoku.dev/demo",
"https://cdn.zudoku.dev/demo/",
"https://cdn.zudoku.dev/demo/index.html",
"https://cdn.zudoku.dev/latest",
"https://cdn.zudoku.dev/latest/",
"https://cdn.zudoku.dev/latest/index.html",
"https://cdn.zudoku.dev/latest/main.js",
"https://cdn.zudoku.dev/latest/demo.js",
"https://cdn.zudoku.dev/latest/style.css"
]
}'
- name: Write Summary
run: |
echo "📝 Bundle stats uploaded" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "[View Stats](https://cdn.zudoku.dev/build/rollup/${{ github.run_id }}-${{ github.run_attempt }}/stats.html)" >> $GITHUB_STEP_SUMMARY
- uses: ncipollo/release-action@v1
if: env.RELEASE_TYPE != 'prerelease'
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Trigger updates of internal projects using Zudoku
- run: gh workflow run release.yaml --repo zuplo-poc/docs-zudoku --ref main
env:
GITHUB_TOKEN: ${{ secrets.GH_SECRET_TRIGGER_POC_WORKFLOWS }}