forked from coral-xyz/backpack
-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (185 loc) Β· 7.97 KB
/
pull_requests_and_merges.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# Actions that run when opening or updating pull requests, as well
# as when merging them into master or pushing code directly to master
name: Pull Requests and Merges
on:
pull_request:
types: [opened, synchronize]
branches:
- master
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-latest
name: Build and run tests
env:
RELEASE_PREFIX: "0.5.2"
steps:
##########################################################################
# Setup environment.
##########################################################################
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
##########################################################################
# Yarn install.
##########################################################################
- name: yarn install
run: yarn install --immutable
##########################################################################
# Build extension.
##########################################################################
#
# Build the extension, beta release.
#
- name: "build beta"
env:
BACKPACK_CONFIG_VERSION: "${{ env.RELEASE_PREFIX }}-latest-beta-${{ github.run_number }}"
BACKPACK_CONFIG_GITHUB_RUN_NUMBER: "${{ github.run_number }}"
BACKPACK_CONFIG_LOG_LEVEL: "info"
BACKPACK_FEATURE_LIGHT_MODE: "true"
BACKPACK_FEATURE_POP_MODE: "true"
BACKPACK_FEATURE_XNFT: "true"
BACKPACK_FEATURE_FORCE_LATEST_VERSION: "true"
# CI!=true so that build warnings aren't treated like errors (for now)
CI: ""
run: yarn build
- name: "rename beta build"
working-directory: packages/app-extension
run: mv build build-beta
##########################################################################
# Yarn test.
##########################################################################
- run: yarn test
##########################################################################
# GitHub Pages (mobile app and hardware wallet support)
##########################################################################
- name: Build background-service-worker.html
run: cd packages/background && yarn build:html
- if: github.event_name == 'pull_request'
name: "set env.commit_sha from latest commit in PR"
run: echo "commit_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- if: github.event_name == 'push'
name: "set env.commit_sha from commit or merge commit"
run: echo "commit_sha=${{ github.sha }}" >> $GITHUB_ENV
- name: "set env.short_sha"
run: echo "short_sha=`echo "${{ env.commit_sha }}" | cut -c1-7`" >> $GITHUB_ENV
- name: (Github Pages) Deploy background-service-worker.html
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
cname: mobile-service-worker.xnfts.dev
publish_dir: packages/background/build
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: "background-scripts/${{ env.short_sha }}"
- name: (Github Pages) Deploy ledger injection
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
publish_dir: packages/ledger-injection/dist
deploy_key: ${{ secrets.LEDGER_INJECTION_DEPLOY_KEY }}
external_repository: coral-xyz/ledger-injection
##########################################################################
# Upload build artifacts.
##########################################################################
#
# Upload beta artifact.
#
- name: "zip beta build artifacts"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
working-directory: packages/app-extension
run: zip -r build-beta-${{ github.run_number }}.zip build-beta/
- name: "upload build artifacts"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v2
with:
name: backpack-build-beta
path: packages/app-extension/build-beta-${{ github.run_number }}.zip
##########################################################################
# Release.
##########################################################################
#
# TODO: the master branch conditionson all these are bit hacky. Probably
# a cleaner way of doing this.
#
#
# Download artifacts.
#
- uses: actions/download-artifact@v2
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
name: backpack-build-beta
path: ./
#
# Create release.
#
- uses: actions/create-release@v1
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
name: Create Draft Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_PREFIX }}-latest-${{ github.run_number }}
release_name: ${{ env.RELEASE_PREFIX }}-latest-${{ github.run_number }}
draft: false
prerelease: false
#
# Attach files to the release.
#
- uses: actions/[email protected]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build-beta-${{ github.run_number }}.zip
asset_name: build-beta-${{ github.run_number }}.zip
asset_content_type: application/zip
##########################################################################
# NPM Publish.
##########################################################################
- name: "update npm package version"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: ./scripts/npm_release.sh ${{ env.RELEASE_PREFIX }}-latest.${{ github.run_number }}
- name: "publish to npm: common"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/common/package.json
- name: "publish to npm: themes"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/themes/package.json
- name: "publish to npm: @coral-xyz/xnft-cli"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/xnft-cli/package.json
- name: "change @coral-xyz/xnft-cli package name to xnft"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: sed -i 's/"@coral-xyz\/xnft-cli"/"xnft"/g' packages/xnft-cli/package.json
- name: "publish to npm: xnft"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/xnft-cli/package.json
- name: "publish to npm: chat-sdk"
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_ACCESS_TOKEN }}
tag: latest
package: packages/chat-sdk/package.json