-
Notifications
You must be signed in to change notification settings - Fork 75
124 lines (118 loc) · 5.43 KB
/
deploy.yml
File metadata and controls
124 lines (118 loc) · 5.43 KB
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
# 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/build-push-action@v3.1.1
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' }}
npm-publish:
runs-on: ubuntu-latest
container:
image: rust:1.61
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3.4.1
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@6720f05bc48b77f96918929a9019fb2203ff71f8 # v2.0.0
- 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@0f451a94170d1699fd50710966d48fb26194d939 # v1.4.3
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/setup-node@v3.4.1
with:
node-version: 12
- uses: denoland/setup-deno@004814556e37c54a2f6e31384c9e18e983317366 # v1.1.0
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@6720f05bc48b77f96918929a9019fb2203ff71f8 # v2.0.0
- 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, npm-publish, deno-publish]
runs-on: ubuntu-latest
steps:
- run: echo Success