-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (150 loc) · 5.36 KB
/
build-test-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
name: Run build, test & publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
on:
workflow_dispatch:
push:
branches:
- develop
- main
- master
- beta
- nightly
- feature-lib
pull_request:
branches:
- develop
- main
jobs:
build:
if: contains(github.event.pull_request.title, ':tada:') == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-js-workflow
- name: Build and check size
if: github.event_name == 'pull_request'
uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_step: install
- name: Build
if: github.event_name != 'pull_request'
run: pnpm build
test:
if: contains(github.event.pull_request.title, ':tada:') == false
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-js-workflow
- name: Test
run: pnpm test:coverage
- uses: codecov/codecov-action@v3
with:
files: ./internal/helpers/coverage/coverage-final.json,./packages/toolboxes/evm/coverage/coverage-final.json,./packages/swapkit/swapkit-core/coverage/coverage-final.json
flags: unittests
name: swapkit-codecov
fail_ci_if_error: false
verbose: true
lint:
if: contains(github.event.pull_request.title, ':tada:') == false
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-js-workflow
- name: Lint
run: pnpm lint
publish:
if: contains(github.ref_name, 'develop') || contains(github.ref_name, 'main') || contains(github.ref_name, 'nightly') || contains(github.ref_name, 'beta')
needs: [build, test, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-js-workflow
- name: Set job params
shell: bash
id: deployment-params
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Copy npmrc config
run: cp .npmrc.prod .npmrc
- name: Change nightly changeset
if: contains(github.ref_name, 'nightly')
run: |
pnpm changeset pre exit
pnpm changeset version --snapshot nightly
- name: Change beta changeset
if: contains(github.ref_name, 'beta')
run: |
echo 'publishName="Beta"' >> $GITHUB_OUTPUT
pnpm changeset pre exit
pnpm changeset pre enter beta
- name: Change stable changeset
if: contains(github.ref_name, 'main')
run: |
echo 'publishName="Release"' >> $GITHUB_OUTPUT
pnpm changeset pre exit
- name: Create Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
if: contains(github.ref_name, 'main') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'develop')
with:
title: ':tada: Publish ${{ steps.deployment-params.outputs.publishName }}'
version: pnpm version-bump
publish: pnpm publish-packages
setupGitUser: false
- name: Internal Discord Notification
if: ${{ steps.changesets.outputs.published == 'true' }}
uses: sarisia/actions-status-discord@82409b24a08684f54ea5baa6b376e36dad37fb81
with:
noprefix: ${{ job.status == 'success' }}
avatar_url: https://static.thorswap.net/logo.png
color: ${{ contains(github.ref_name, 'main') && '0x00aa00' || '0x3af3f4' }}
description: "Internal build ${{ job.status }}: ${{ github.ref_name }}:\n${{ steps.changesets.outputs.publishedPackages }}"
status: success
url: 'https://github.com/thorswap/swapkit/releases'
username: SwapKit - ${{ github.ref_name }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
- name: Publish Nightly to npm
uses: changesets/action@v1
if: contains(github.ref_name, 'nightly')
with:
title: ':tada: Publish Nightly'
version: pnpm version-bump
publish: pnpm publish-packages --tag nightly
setupGitUser: false
- name: Revert base changeset
if: contains(github.ref_name, 'nightly') || contains(github.ref_name, 'main')
run: |
pnpm changeset pre enter rc
- name: Revert changeset beta prelease
if: contains(github.ref_name, 'beta')
run: |
pnpm changeset pre exit
pnpm changeset pre enter rc
deploy-playground:
if: contains(github.ref_name, 'develop')
needs: [build, test, lint]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-js-workflow
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build playground
run: pnpm build:playground
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './internal/playground/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2