-
Notifications
You must be signed in to change notification settings - Fork 114
153 lines (141 loc) Β· 5.31 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
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
name: Build
on:
push:
env:
SDK_ERROR_MESSAGES_VERSION: "master"
V4_API_KEY_MAINNET: ${{ secrets.V4_API_KEY_MAINNET }}
V4_API_KEY_TESTNET: ${{ secrets.V4_API_KEY_TESTNET }}
V3_API_KEY_MAINNET: ${{ secrets.V3_API_KEY_MAINNET }}
V3_API_KEY_TESTNET: ${{ secrets.V3_API_KEY_TESTNET }}
NON_TATUM_RPC_ETH_URL: ${{ secrets.NON_TATUM_RPC_ETH_URL }}
VERBOSE: ${{ secrets.verbose }}
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
current_branch: ${{ steps.branch-name.outputs.current_branch }}
package_version: ${{ env.package_version }}
release_exists: ${{ env.release_exists }}
release_prerelease: ${{ steps.semver-utils.outputs.prerelease }}
package_tag: ${{ env.package_tag }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
- uses: actions/checkout@v3
- name: Get package version
id: package-version
run: |
version=$(jq -r '.version' package.json)
echo "package_version=$version" >> "$GITHUB_ENV"
- name: Check if release for package version already exists
id: release-exists
run: |
curl --fail --silent --max-time 5 "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${{ env.package_version }}" && echo "release_exists=true" >> $GITHUB_ENV || echo "release_exists=false" >> $GITHUB_ENV
- name: Get semver data
uses: madhead/semver-utils@v3
id: semver-utils
with:
lenient: false
version: ${{ env.package_version }}
- name: NPM release tag
id: npm-release-tag
run: |
[[ "${{ steps.semver-utils.outputs.prerelease }}" == "" ]] && echo "package_tag=latest" >> $GITHUB_ENV || echo "package_tag=${{ env.package_version }}" >> $GITHUB_ENV
build:
runs-on: ubuntu-latest
needs: [metadata]
strategy:
fail-fast: false
matrix:
nodejs: [ 18 ]
steps:
- uses: actions/checkout@v3
- name: Download SDK error messages
run: curl --fail --silent https://raw.githubusercontent.com/tatumio/tatum-sdk-error-mesages/$SDK_ERROR_MESSAGES_VERSION/error-messages.json --output resources/error-messages.json
# https://github.com/actions/setup-node
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.nodejs }}
cache: 'yarn'
- run: yarn install
- run: yarn build-all
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.nodejs }}
path: dist/
retention-days: 7
if: |
needs.metadata.outputs.current_branch == 'master' ||
contains(github.event.head_commit.message, 'release prerelease')
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# https://github.com/actions/setup-node
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- run: yarn install
- run: yarn lint
- run: yarn test
env:
V4_API_KEY_MAINNET: ${{ secrets.V4_API_KEY_MAINNET }}
V3_API_KEY_MAINNET: ${{ secrets.V3_API_KEY_MAINNET }}
V3_API_KEY_TESTNET: ${{ secrets.V3_API_KEY_TESTNET }}
NON_TATUM_RPC_ETH_URL: ${{ secrets.NON_TATUM_RPC_ETH_URL }}
VERBOSE: ${{ secrets.verbose }}
- uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: TEST REPORT
path: reports/jest-junit.xml
reporter: jest-junit
release:
runs-on: ubuntu-latest
if: needs.metadata.outputs.current_branch == 'master' && needs.metadata.outputs.release_exists == 'false'
needs: [ metadata, build, test ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Git config
run: |
git config --local user.name github-actions
git config --local user.email [email protected]
- name: Get release notes
id: get_release_notes
uses: ffurrer2/extract-release-notes@v1
# TAG the repo
- name: Create tag ${{needs.metadata.outputs.package_version}}
uses: rickstaa/action-create-tag@v1
with:
tag: "${{needs.metadata.outputs.package_version}}"
- name: "Create a GitHub release ${{ needs.metadata.outputs.package_version }}"
# Create release using the tag above
uses: ncipollo/release-action@v1
with:
tag: "${{needs.metadata.outputs.package_version}}"
name: "${{needs.metadata.outputs.package_version}}"
body: |
${{ steps.get_release_notes.outputs.release_notes }}
npm:
runs-on: ubuntu-latest
if: |
(needs.metadata.outputs.current_branch == 'master' && needs.metadata.outputs.release_exists == 'false') ||
(needs.metadata.outputs.current_branch != 'master' && needs.metadata.outputs.release_prerelease != '' && contains(github.event.head_commit.message, 'release prerelease'))
needs: [ metadata, build, test ]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-18
path: dist
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: yarn publish --access public --tag ${{ needs.metadata.outputs.package_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}