-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (112 loc) · 3.49 KB
/
deploy-js.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: Deploy JS Client
on:
workflow_dispatch:
inputs:
bump:
description: Version bump
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- prerelease
- prepatch
- preminor
- premajor
tag:
description: NPM Tag (and preid for pre-releases)
required: true
type: string
default: latest
create_release:
description: Create a GitHub release
required: true
type: boolean
default: true
env:
CACHE: true
jobs:
build_programs:
name: Programs
uses: ./.github/workflows/build-programs.yml
secrets: inherit
test_js:
name: JS client
needs: build_programs
uses: ./.github/workflows/test-js.yml
secrets: inherit
deploy_js:
name: JS client / Deploy
runs-on: ubuntu-latest
needs: test_js
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Install Node.js
uses: metaplex-foundation/actions/install-node-with-pnpm@v1
with:
version: ${{ env.NODE_VERSION }}
cache: ${{ env.CACHE }}
- name: Install dependencies
uses: metaplex-foundation/actions/install-node-dependencies@v1
with:
folder: ./clients/js
cache: ${{ env.CACHE }}
key: clients-js
- name: Build
working-directory: ./clients/js
run: pnpm build
- name: Bump
id: bump
working-directory: ./clients/js
run: |
if [ "${{ startsWith(inputs.bump, 'pre') }}" == "true" ]; then
pnpm version ${{ inputs.bump }} --preid ${{ inputs.tag }} --no-git-tag-version
else
pnpm version ${{ inputs.bump }} --no-git-tag-version
fi
echo "new_version=$(pnpm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
working-directory: ./clients/js
run: pnpm publish --no-git-checks --tag ${{ inputs.tag }}
- name: Commit and tag new version
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Deploy JS client v${{ steps.bump.outputs.new_version }}
tagging_message: js@v${{ steps.bump.outputs.new_version }}
- name: Create GitHub release
if: github.event.inputs.create_release == 'true'
uses: ncipollo/release-action@v1
with:
tag: js@v${{ steps.bump.outputs.new_version }}
deploy_js_docs:
name: JS client / Deploy docs
runs-on: ubuntu-latest
needs: deploy_js
environment:
name: js-client-documentation
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
- name: Deploy to Vercel
id: deploy
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: ./clients/js
run: echo "url=$(vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }})" | tee $GITHUB_OUTPUT