@@ -3,6 +3,14 @@ name: Publish JS Client
33on :
44 workflow_dispatch :
55 inputs :
6+ package_path :
7+ description : Path to directory with package to release
8+ required : true
9+ default : ' clients/js'
10+ type : choice
11+ options :
12+ - clients/js
13+ - clients/js-legacy
614 level :
715 description : Version level
816 required : true
2836 default : true
2937
3038jobs :
31- test_js :
32- name : Test JS client
39+ test :
40+ name : Test JS package
3341 runs-on : ubuntu-latest
3442 steps :
3543 - name : Git Checkout
@@ -39,42 +47,74 @@ jobs:
3947 uses : ./.github/actions/setup
4048 with :
4149 solana : true
50+ cargo-cache-key : cargo-js-test-publish-${{ inputs.package_path }}
51+ cargo-cache-fallback-key : cargo-js-test-publish
52+
53+ - name : Format
54+ run : pnpm zx ./scripts/js/format.mjs "${{ inputs.package_path }}"
55+
56+ - name : Lint
57+ run : pnpm zx ./scripts/js/lint.mjs "${{ inputs.package_path }}"
4258
43- - name : Format JS Client
44- run : pnpm clients:js:format
59+ - name : Build Token-2022
60+ run : pnpm programs:build
4561
46- - name : Lint JS Client
47- run : pnpm clients:js:lint
62+ - name : Build ElGamal Registry
63+ run : pnpm confidential-transfer:elgamal-registry:build
4864
49- - name : Test JS Client
50- run : pnpm clients:js: test
65+ - name : Test
66+ run : pnpm zx ./scripts/js/ test.mjs "${{ inputs.package_path }}"
5167
52- publish_js :
53- name : Publish JS client
68+ publish :
69+ name : Publish JS package
5470 runs-on : ubuntu-latest
55- needs : test_js
71+ needs : test
5672 permissions :
5773 contents : write
5874 steps :
5975 - name : Git Checkout
6076 uses : actions/checkout@v4
77+ with :
78+ token : ${{ secrets.ANZA_TEAM_PAT }}
79+ fetch-depth : 0 # get the whole history for git-cliff
6180
6281 - name : Setup Environment
6382 uses : ./.github/actions/setup
6483
65- - name : Ensure NPM_TOKEN variable is set
84+ - name : Ensure SOLANA_NPM_TOKEN variable is set
6685 env :
67- token : ${{ secrets.NPM_TOKEN }}
86+ token : ${{ secrets.SOLANA_NPM_TOKEN }}
6887 if : ${{ env.token == '' }}
6988 run : |
70- echo "The NPM_TOKEN secret variable is not set"
89+ echo "The SOLANA_NPM_TOKEN secret variable is not set"
90+ echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
91+ exit 1
92+
93+ - name : Ensure SOLANA_PROGRAM_NPM_TOKEN variable is set
94+ env :
95+ token : ${{ secrets.SOLANA_PROGRAM_NPM_TOKEN }}
96+ if : ${{ env.token == '' }}
97+ run : |
98+ echo "The SOLANA_PROGRAM_NPM_TOKEN secret variable is not set"
7199 echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
72100 exit 1
73101
74102 - name : NPM Authentication
75- run : pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
76103 env :
77- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
104+ SOLANA_NPM_TOKEN : ${{ secrets.SOLANA_NPM_TOKEN }}
105+ SOLANA_PROGRAM_NPM_TOKEN : ${{ secrets.SOLANA_PROGRAM_NPM_TOKEN }}
106+ shell : bash
107+ run : |
108+ cd "${{ inputs.package_path }}"
109+ org="$(jq '.name|split("/")|.[0]' package.json)"
110+ if [[ $org == "\"@solana-program\"" ]] then
111+ pnpm config set '//registry.npmjs.org/:_authToken' "${SOLANA_PROGRAM_NPM_TOKEN}"
112+ elif [[ $org == "\"@solana\"" ]] then
113+ pnpm config set '//registry.npmjs.org/:_authToken' "${SOLANA_NPM_TOKEN}"
114+ else
115+ echo "Unknown organization: $org"
116+ exit 1
117+ fi
78118
79119 - name : Set Git Author
80120 run : |
@@ -83,13 +123,27 @@ jobs:
83123
84124 - name : Publish JS Client
85125 id : publish
86- run : pnpm clients: js:publish ${{ inputs.level }} ${{ inputs.tag }}
126+ run : pnpm js:publish "${{ inputs.package_path }}" ${{ inputs.level }} ${{ inputs.tag }}
87127
88128 - name : Push Commit and Tag
89129 run : git push origin --follow-tags
90130
131+ - name : Generate a changelog
132+ if : github.event.inputs.create_release == 'true'
133+ uses : orhun/git-cliff-action@v3
134+ with :
135+ config : " scripts/cliff.toml"
136+ args : |
137+ "${{ steps.publish.outputs.old_git_tag }}"..main
138+ --include-path "${{ inputs.package_path }}/**"
139+ --github-repo "${{ github.repository }}"
140+ env :
141+ OUTPUT : TEMP_CHANGELOG.md
142+ GITHUB_REPO : ${{ github.repository }}
143+
91144 - name : Create GitHub release
92145 if : github.event.inputs.create_release == 'true'
93146 uses : ncipollo/release-action@v1
94147 with :
95- tag : js@v${{ steps.publish.outputs.new_version }}
148+ tag : ${{ steps.publish.outputs.new_git_tag }}
149+ bodyFile : TEMP_CHANGELOG.md
0 commit comments