-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (192 loc) · 7.29 KB
/
release.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
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Release
on:
push:
branches: [main]
jobs:
release-please:
name: Create Release
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
stdlib_tag_name: ${{ steps.release.outputs.stdlib--tag_name }}
js-runner_tag_name: ${{ steps.release.outputs.js-runner--tag_name }}
steps:
- uses: GoogleCloudPlatform/[email protected]
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
command: manifest
prepare-artifacts:
needs: [release-please]
if: ${{ needs.release-please.outputs.releases_created }}
name: Prepare artifacts
runs-on: ubuntu-latest
outputs:
stdlib_download_url: ${{ steps.stdlib-upload.outputs.browser_download_url }}
js-runner_download_url: ${{ steps.js-runner-upload.outputs.browser_download_url }}
steps:
- name: Checkout project
uses: actions/checkout@v2
# Many of these steps are the same as building the compiler for tests
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: "16"
check-latest: true
cache: 'npm'
- name: Setup environment
run: |
npm install -g shx
- name: Set up JS runner and CLI
run: |
npm ci
- name: Esy setup
run: |
npm run compiler prepare
- name: Esy cache
id: esy-cache
uses: actions/cache@v2
with:
path: compiler/_export
key: ${{ runner.os }}-esy-${{ hashFiles('compiler/esy.lock/index.json') }}
- name: Import esy cache
if: steps.esy-cache.outputs.cache-hit == 'true'
# Don't crash the run if esy cache import fails - mostly happens on Windows
continue-on-error: true
run: |
npm run compiler import-dependencies
shx rm -rf compiler/_export
# Don't build grainc.exe, only the JS builds
# TODO(#589): Actually build the exe's these once users can install them locally
- name: Build compiler
run: |
npm run compiler build:js
# This will log a warning because we removed the grainc.exe file
- name: Build Binaries
run: |
npm run cli build-pkg -- --target=win-x64,mac-x64,linux-x64
- name: Upload Binary (Windows)
uses: grain-lang/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
file: ./pkg/grain-win.exe
asset_name: grain-win-x64.exe
tag: ${{ needs.release-please.outputs.tag_name }}
- name: Upload Binary (Mac)
uses: grain-lang/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
file: ./pkg/grain-macos
asset_name: grain-mac-x64
tag: ${{ needs.release-please.outputs.tag_name }}
- name: Upload Binary (Linux)
uses: grain-lang/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
file: ./pkg/grain-linux
asset_name: grain-linux-x64
tag: ${{ needs.release-please.outputs.tag_name }}
- name: Pack stdlib
if: ${{ needs.release-please.outputs.releases_created }}
working-directory: ./stdlib
# Runs `npm pack` and assigns the filename to an env var we can use later
# `sed` is used to workaround https://github.com/npm/cli/issues/3405
run: |
echo "STDLIB_TAR=$(npm pack --json | jq -r '.[0].filename' | sed -r 's/@//g' | sed -r 's/\//-/g')" >> $GITHUB_ENV
- name: Upload stdlib
id: stdlib-upload
if: ${{ needs.release-please.outputs.releases_created }}
uses: grain-lang/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
file: ./stdlib/${{ env.STDLIB_TAR }}
asset_name: stdlib.tgz
tag: ${{ needs.release-please.outputs.stdlib_tag_name }}
- name: Pack js-runner
if: ${{ needs.release-please.outputs.releases_created }}
working-directory: ./js-runner
# Runs `npm pack` and assigns the filename to an env var we can use later
# `sed` is used to workaround https://github.com/npm/cli/issues/3405
run: |
echo "RUNNER_TAR=$(npm pack --json | jq -r '.[0].filename' | sed -r 's/@//g' | sed -r 's/\//-/g')" >> $GITHUB_ENV
- name: Upload js-runner
id: js-runner-upload
if: ${{ needs.release-please.outputs.releases_created }}
uses: grain-lang/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
file: ./js-runner/${{ env.RUNNER_TAR }}
asset_name: js-runner.tgz
tag: ${{ needs.release-please.outputs.js-runner_tag_name }}
dispatch-website:
needs: [release-please, prepare-artifacts]
if: ${{ needs.release-please.outputs.releases_created }}
name: Dispatch website release
runs-on: ubuntu-latest
steps:
- uses: grain-lang/[email protected]
with:
workflow: Grain Release
token: ${{ secrets.WORKFLOW_TOKEN }}
ref: master
repo: grain-lang/grain-lang.org
tag_input: ${{ needs.release-please.outputs.tag_name }}
dispatch-homebrew:
needs: [release-please, prepare-artifacts]
if: ${{ needs.release-please.outputs.releases_created }}
name: Dispatch homebrew release
runs-on: ubuntu-latest
steps:
- uses: grain-lang/[email protected]
with:
workflow: Grain Release
token: ${{ secrets.WORKFLOW_TOKEN }}
ref: main
repo: grain-lang/homebrew-tap
tag_input: ${{ needs.release-please.outputs.tag_name }}
dispatch-docker:
needs: [release-please, prepare-artifacts]
if: ${{ needs.release-please.outputs.releases_created }}
name: Dispatch Docker builds
runs-on: ubuntu-latest
steps:
- uses: grain-lang/[email protected]
with:
workflow: Publish Docker images
token: ${{ secrets.WORKFLOW_TOKEN }}
ref: main
repo: grain-lang/grain
tag_input: ${{ needs.release-please.outputs.tag_name }}
npm-release-stdlib:
needs: [release-please, prepare-artifacts]
if: ${{ needs.release-please.outputs.releases_created }}
name: Publish stdlib to npm registry
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/[email protected]
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
- name: Publish to npm
run: |
npm publish ${{ needs.prepare-artifacts.outputs.stdlib_download_url }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE }}
npm-release-js-runner:
needs: [release-please, prepare-artifacts]
if: ${{ needs.release-please.outputs.releases_created }}
name: Publish js-runner to npm registry
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/[email protected]
with:
node-version: "16"
registry-url: "https://registry.npmjs.org"
- name: Publish to npm
run: |
npm publish ${{ needs.prepare-artifacts.outputs.js-runner_download_url }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE }}