|
| 1 | +name: Publish JS Client |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + level: |
| 7 | + description: Version level |
| 8 | + required: true |
| 9 | + default: patch |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + - prerelease |
| 16 | + - prepatch |
| 17 | + - preminor |
| 18 | + - premajor |
| 19 | + tag: |
| 20 | + description: NPM Tag (and preid for pre-releases) |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + default: latest |
| 24 | + create_release: |
| 25 | + description: Create a GitHub release |
| 26 | + required: true |
| 27 | + type: boolean |
| 28 | + default: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + test_js: |
| 32 | + name: Test JS client |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Git Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Setup Environment |
| 39 | + uses: ./.github/actions/setup |
| 40 | + with: |
| 41 | + cargo-cache-key: cargo-programs |
| 42 | + solana: true |
| 43 | +{% if programFramework === 'anchor' %} |
| 44 | + anchor: true |
| 45 | +{% endif %} |
| 46 | + |
| 47 | + - name: Format JS Client |
| 48 | + run: pnpm clients:js:format |
| 49 | + |
| 50 | + - name: Lint JS Client |
| 51 | + run: pnpm clients:js:lint |
| 52 | + |
| 53 | + - name: Build Programs |
| 54 | + run: pnpm programs:build |
| 55 | + |
| 56 | + - name: Test JS Client |
| 57 | + run: pnpm clients:js:test |
| 58 | + |
| 59 | + publish_js: |
| 60 | + name: Publish JS client |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: test_js |
| 63 | + permissions: |
| 64 | + contents: write |
| 65 | + steps: |
| 66 | + - name: Git Checkout |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Setup Environment |
| 70 | + uses: ./.github/actions/setup |
| 71 | + |
| 72 | + - name: Ensure NPM_TOKEN variable is set |
| 73 | + env: |
| 74 | + token: {% raw %}${{ secrets.NPM_TOKEN }}{% endraw %} |
| 75 | + if: {% raw %}${{ env.token == '' }}{% endraw %} |
| 76 | + run: | |
| 77 | + echo "The NPM_TOKEN secret variable is not set" |
| 78 | + echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"." |
| 79 | + exit 1 |
| 80 | + |
| 81 | + - name: NPM Authentication |
| 82 | + run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}" |
| 83 | + env: |
| 84 | + NODE_AUTH_TOKEN: {% raw %}${{ secrets.NPM_TOKEN }}{% endraw %} |
| 85 | + |
| 86 | + - name: Set Git Author |
| 87 | + run: | |
| 88 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 89 | + git config --global user.name "github-actions[bot]" |
| 90 | + |
| 91 | + - name: Publish JS Client |
| 92 | + id: publish |
| 93 | + run: pnpm clients:js:publish {% raw %}${{ inputs.level }} ${{ inputs.tag }}{% endraw %} |
| 94 | + |
| 95 | + - name: Push Commit and Tag |
| 96 | + run: git push origin --follow-tags |
| 97 | + |
| 98 | + - name: Create GitHub release |
| 99 | + if: github.event.inputs.create_release == 'true' |
| 100 | + uses: ncipollo/release-action@v1 |
| 101 | + with: |
| 102 | + tag: {% raw %}js@v${{ steps.publish.outputs.new_version }}{% endraw %} |
0 commit comments