-
Notifications
You must be signed in to change notification settings - Fork 29
72 lines (67 loc) · 2.44 KB
/
build.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
name: build
on:
push:
branches:
- master
tags:
- v*
pull_request:
jobs:
ci:
runs-on: ${{ matrix.os }}
env:
#hardcode the coveralls token...it's not overly important to protect, and github actions won't allow forks to work with coveralls otherwise
COVERALLS_REPO_TOKEN: "ppWEadjj41ovqxQn4LelJ0TAtCKuMNDaH"
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "16.20.2"
architecture: 'x64' # fix for macos-latest
- run: cd bsc-plugin && npm install
- run: cd bsc-plugin && npm run preversion
- run: cd bsc-plugin && npm run publish-coverage
- run: cd tests && npm install && npm run build
npm-release:
#only run this task if a tag starting with 'v' was used to trigger this (i.e. a tagged release)
if: startsWith(github.ref, 'refs/tags/v')
needs: ci
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "16.20.2"
architecture: 'x64' # fix for macos-latest
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ./.npmrc
- run: cd bsc-plugin && npm ci
- run: cd bsc-plugin && npm run build
#create npm package
- run: cd bsc-plugin && npm pack
#create GitHub release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false #contains(github.ref, '-beta.') == true
#upload package to GitHub release
- name: Upload GitHub Release Assets
uses: alexellis/upload-assets@0.2.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["./bsc-plugin/*.tgz"]'
#If there's a dash followed by an alpha character, this is a prerelease and should be tagged "next". Otherwise tag as "latest"
- run: if [[ "${{ github.ref }}" =~ -[a-zA-Z] ]]; then echo "DIST_TAG=next" >> $GITHUB_ENV; else echo "DIST_TAG=latest" >> $GITHUB_ENV; fi
#upload to npm
- run: cd bsc-plugin && npm publish --tag ${{env.DIST_TAG}}