-
Notifications
You must be signed in to change notification settings - Fork 18
129 lines (105 loc) · 3.69 KB
/
CI-CD-gear-js-api.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
name: 'CI-CD @gear-js/api'
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
branches: [main]
push:
branches: [main]
paths:
- api/**
workflow_dispatch:
env:
NIGHTLY_TOOLCHAIN_VERSION: ${{ vars.NIGHTLY_TOOLCHAIN_VERSION }}
jobs:
test:
if: github.event_name == 'pull_request'
runs-on: ubuntu-22.04
env:
RUSTUP_HOME: /tmp/rustup_home
steps:
- name: Cancel previous workflow runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- name: "Install: NodeJS 18.x"
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: "Install: Set cargo path"
run: echo "/tmp/cargo/bin" >> $GITHUB_PATH
- name: "Install: Nightly toolchain"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
components: llvm-tools-preview
- name: "Install: Show specific nightly version"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
run: echo $NIGHTLY_TOOLCHAIN_VERSION | sed 's/-/ - /g'
- name: "Install: Specific nightly toolchain"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-${{ env.NIGHTLY_TOOLCHAIN_VERSION }}
target: wasm32-unknown-unknown
components: llvm-tools-preview
- name: "Install: Pin to specific nightly toolchain"
if: ${{ env.NIGHTLY_TOOLCHAIN_VERSION != '' }}
run: |
rm -rf $RUSTUP_HOME/toolchains/nightly-x86_64-unknown-linux-gnu
ln -s $RUSTUP_HOME/toolchains/nightly-$NIGHTLY_TOOLCHAIN_VERSION-x86_64-unknown-linux-gnu $RUSTUP_HOME/toolchains/nightly-x86_64-unknown-linux-gnu
- name: "Install: pkg dependencies"
working-directory: api
run: yarn install
- name: "Build: @gear-js/api"
working-directory: api
run: yarn build
- name: "Prepare: build programs"
working-directory: api/programs
run: cargo build --locked
- name: "Prepare: download Gear node"
run: |
wget -O ./gear https://github.com/gear-tech/gear/releases/download/build/gear
chmod +x gear
- name: "Prepare: run Gear node"
run: |
nohup ./gear --dev --execution=wasm --tmp --unsafe-rpc-external --rpc-methods Unsafe --rpc-cors all &
- name: "Prepare: sleep 3 min"
run: sleep 180
- name: "Test: run"
working-directory: api
run: yarn test
publish-to-npm:
if: github.event_name == 'push'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Use node 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Check package version
uses: EndBug/version-check@v1
id: check
with:
file-name: api/package.json
file-url: https://unpkg.com/@gear-js/api@latest/package.json
static-checking: localIsNew
- name: Install dependencies
if: steps.check.outputs.changed == 'true'
working-directory: api
run: yarn install
- name: Build @gear-js/api
if: steps.check.outputs.changed == 'true'
working-directory: api
run: yarn build
- name: Publish
if: steps.check.outputs.changed == 'true'
working-directory: api/lib
run: |
export token=$(printenv $(printenv GITHUB_ACTOR))
npm config set //registry.npmjs.org/:_authToken=$token
npm publish
env:
osipov-mit: ${{ secrets.OSIPOV_NPM_TOKEN }}