-
Notifications
You must be signed in to change notification settings - Fork 13
263 lines (229 loc) · 7.53 KB
/
publish.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Publish packages
on:
release:
types: [published]
workflow_dispatch:
jobs:
publish-binaries:
name: Build and publish binaries
strategy:
matrix:
rust_toolchain: [stable]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.os }}
if: contains(github.ref, 'vscode-extension') != true
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust_toolchain }}
override: true
- name: Build CLI
if: matrix.os == 'ubuntu-latest'
run: |
cargo b --release --bin cddl
cp target/release/cddl cddl-linux-amd64
chmod +x cddl-linux-amd64
tar -czvf cddl-linux-amd64.tar.gz cddl-linux-amd64
- name: Build CLI
if: matrix.os == 'macOS-latest'
run: |
cargo b --release --bin cddl
cp target/release/cddl cddl-darwin-amd64
chmod +x cddl-darwin-amd64
zip cddl-darwin-amd64.zip cddl-darwin-amd64
- name: Build CLI
if: matrix.os == 'windows-latest'
shell: powershell
run: |
cargo b --release --bin cddl
cp target\release\cddl.exe cddl-windows-amd64.exe
Compress-Archive -Path .\cddl-windows-amd64.exe -DestinationPath cddl-windows-amd64.zip
- name: Upload binary asset
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cddl-linux-amd64.tar.gz
asset_name: cddl-linux-amd64.tar.gz
asset_content_type: application/zip
- name: Upload binary asset
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cddl-windows-amd64.zip
asset_name: cddl-windows-amd64.zip
asset_content_type: application/zip
- name: Upload binary asset
if: matrix.os == 'macOS-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cddl-darwin-amd64.zip
asset_name: cddl-darwin-amd64.zip
asset_content_type: application/zip
publish-docker:
name: Publish Docker
runs-on: ubuntu-latest
if: contains(github.ref, 'vscode-extension') != true
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ghcr.io/anweiss/cddl-cli
tag-semver: |
{{version}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCRPAT }}
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
publish-npm:
name: Publish npm
runs-on: ubuntu-latest
if: contains(github.ref, 'vscode-extension') != true
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: wasm32-unknown-unknown
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: "16"
- name: Install wasmpack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build wasm default features
run: |
wasm-pack build --target nodejs --scope anweiss --release
- name: Build wasm lsp feature
run: |
wasm-pack build --target nodejs --scope anweiss --release --out-dir cddl-languageserver -- --features lsp
sed -i -e 's/"name": "@anweiss\/cddl"/"name": "@anweiss\/cddl-languageserver"/g' cddl-languageserver/package.json
- name: Publish to GPR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN" > ~/.npmrc
cp .npmrc pkg/
cp .npmrc cddl-languageserver/
cd pkg
npm publish --access=public
cd ../cddl-languageserver
npm publish --access=public
publish-vscode-extension:
name: Publish vscode extension
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: "16"
- name: Deploy to Marketplace
working-directory: ./cddl-lsp
env:
VSCODE_MARKETPLACE_TOKEN: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
run: |
sudo apt-get update && sudo apt-get install -y jq
npm install -g vsce
export TAG=`jq -r '.version' package.json`
vsce show --json anweiss.cddl-languageserver | jq -e --arg TAG "$TAG" -e '.versions[] | select(.version == $TAG)'
if [ "$?" -ne 0 ]
then
npm install
npm run deploy -- -p $VSCODE_MARKETPLACE_TOKEN
fi
publish-crate:
name: Publish crate
strategy:
matrix:
rust_toolchain: [stable]
runs-on: ubuntu-latest
if: contains(github.ref, 'vscode-extension') != true
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust_toolchain }}
override: true
- name: Login to crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CratesIOToken }}
- name: Publish crate
uses: actions-rs/cargo@v1
with:
command: publish
publish-website:
name: Publish website
runs-on: ubuntu-latest
if: contains(github.ref, 'vscode-extension') != true
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: wasm32-unknown-unknown
- name: Install wasmpack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Install node
uses: actions/setup-node@v1
with:
node-version: "16"
- name: Build wasm
run: |
wasm-pack build --release
- name: Build web
run: |
cd www
npm install
npm run build
- name: Deploy web
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: www/dist