-
Notifications
You must be signed in to change notification settings - Fork 74
162 lines (155 loc) · 6.62 KB
/
deploy.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
# Smoldot
# Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
# SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
name: deploy
on:
pull_request: # All deployment steps are tested on PRs, but the actual deployment doesn't happen.
push:
branches:
- main
jobs:
build-push-docker-image:
runs-on: ubuntu-latest
steps:
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- uses: docker/login-action@v2
# This `if` adds an additional safety against accidental pushes.
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/[email protected]
with:
context: .
file: ./bin/full-node/Dockerfile
load: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: docker.pkg.github.com/paritytech/smoldot/node:main
- run: docker push docker.pkg.github.com/paritytech/smoldot/node:main
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
docs-publish:
runs-on: ubuntu-latest
container:
image: rust:1
steps:
- uses: actions/checkout@v3
with:
path: repo
- uses: actions/[email protected]
with:
node-version: current
- run: npm install
working-directory: ./repo/bin/wasm-node/javascript
- uses: Swatinem/rust-cache@v2
- run: cargo doc --verbose --all-features --no-deps --package smoldot --package smoldot-light
working-directory: ./repo
- run: npm run doc
working-directory: ./repo/bin/wasm-node/javascript
- run: |
mkdir -p ./upload/doc-rust
mkdir -p ./upload/doc-javascript
mv ./repo/target/doc/* ./upload/doc-rust
mv ./repo/bin/wasm-node/javascript/dist/doc/* ./upload/doc-javascript
- run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"
git config user.password ${{ secrets.GITHUB_TOKEN }}
git checkout --orphan gh-pages
git rm -rf .
git clean -d --force
mv ../upload/* .
git add --all
git commit -m "Documentation"
working-directory: ./repo
- run: git push -f origin gh-pages:gh-pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
working-directory: ./repo
npm-publish:
runs-on: ubuntu-latest
container:
image: rust:1.65
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
node-version: 12 # An old version is intentionally used in order to check compatibility
- run: apt-get update && apt install -y binaryen # For `wasm-opt`
- uses: actions-rs/toolchain@v1
with:
# Ideally we don't want to install any toolchain, but the GH action doesn't support this.
toolchain: stable
profile: minimal
- uses: Swatinem/rust-cache@v2
- run: npm install
working-directory: ./bin/wasm-node/javascript
- run: npm publish --unsafe-perm --dry-run
working-directory: ./bin/wasm-node/javascript
- uses: JS-DevTools/npm-publish@v1
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
# Warning: this GitHub action doesn't seem to run prepublish scripts, hence
# the `npm publish --dry-run` done right above is important to ensure this.
with:
token: ${{ secrets.NPM_TOKEN }}
package: ./bin/wasm-node/javascript/package.json
access: public
deno-publish:
runs-on: ubuntu-latest
# This action checks if a certain git tag exists. If not, it compiles the JavaScript package,
# then commits the compilation artifacts, tags the commit, and pushes the tag.
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Necessary below for checking if the tag exists.
- uses: actions/[email protected]
with:
node-version: 12
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: sudo apt-get update && sudo apt install -y binaryen # For `wasm-opt`
- uses: actions-rs/toolchain@v1
with:
# Ideally we don't want to install any toolchain, but the GH action doesn't support this.
toolchain: stable
profile: minimal
- uses: Swatinem/rust-cache@v2
- id: compute-tag # Compute the tag that we might push.
run: echo "::set-output name=tag::light-js-deno-v`jq -r .version ./bin/wasm-node/javascript/package.json`"
- id: check-tag-exists # Check whether the tag already exists.
run: echo "::set-output name=num-existing::`git tag -l | grep ${{ steps.compute-tag.outputs.tag }} | wc -l`"
- run: npm install
working-directory: ./bin/wasm-node/javascript
- run: npm publish --unsafe-perm --dry-run
working-directory: ./bin/wasm-node/javascript
- run: |
git add --force ./bin/wasm-node/javascript/dist/mjs # --force bypasses the .gitignore
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Deno version publishing"
- run: |
git tag ${{ steps.compute-tag.outputs.tag }}
if: ${{ steps.check-tag-exists.outputs.num-existing == 0 }}
- run: git push origin ${{ steps.compute-tag.outputs.tag }}
if: ${{ steps.check-tag-exists.outputs.num-existing == 0 && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
all-deploy:
# This dummy job depends on all the mandatory checks. It succeeds if and only if CI is
# considered successful.
needs: [build-push-docker-image, docs-publish, npm-publish, deno-publish]
runs-on: ubuntu-latest
steps:
- run: echo Success