Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 14 additions & 113 deletions .github/workflows/publish-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish JS
on:
workflow_dispatch:
inputs:
package_path:
package-path:
description: Path to directory with package to release
required: true
default: 'clients/js'
Expand All @@ -29,7 +29,7 @@ on:
required: true
type: string
default: latest
create_release:
create-release:
description: Create a GitHub release
required: true
type: boolean
Expand All @@ -51,117 +51,18 @@ jobs:
shell: bash
run: |
echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT"
TARGET=$(echo ${{ inputs.package_path }} | sed 's#/#-#')
TARGET=$(echo ${{ inputs.package-path }} | sed 's#/#-#')
echo "TARGET=$TARGET" >> "$GITHUB_OUTPUT"

test:
name: Test package
main:
needs: set_env
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: solana-program/actions/setup-ubuntu@main
with:
solana: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }}
cargo-cache-key: cargo-publish-js-test-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-publish-js-test

- name: Format
run: make format-check-${{ needs.set_env.outputs.TARGET }}

- name: Lint
run: make lint-${{ needs.set_env.outputs.TARGET }}

- name: Build Token-2022
run: make build-sbf-program

- name: Build ElGamal Registry
run: make build-sbf-confidential-elgamal-registry

- name: Test
run: make test-${{ needs.set_env.outputs.TARGET }}

publish:
name: Publish package
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
steps:
- name: Git Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.ANZA_TEAM_PAT }}
fetch-depth: 0 # get the whole history for git-cliff

- name: Setup Environment
uses: solana-program/actions/setup-ubuntu@main
with:
pnpm: true

- name: Ensure SOLANA_NPM_TOKEN variable is set
env:
token: ${{ secrets.SOLANA_NPM_TOKEN }}
if: ${{ env.token == '' }}
run: |
echo "The SOLANA_NPM_TOKEN secret variable is not set"
echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
exit 1

- name: Ensure SOLANA_PROGRAM_NPM_TOKEN variable is set
env:
token: ${{ secrets.SOLANA_PROGRAM_NPM_TOKEN }}
if: ${{ env.token == '' }}
run: |
echo "The SOLANA_PROGRAM_NPM_TOKEN secret variable is not set"
echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
exit 1

- name: NPM Authentication
env:
SOLANA_NPM_TOKEN: ${{ secrets.SOLANA_NPM_TOKEN }}
SOLANA_PROGRAM_NPM_TOKEN: ${{ secrets.SOLANA_PROGRAM_NPM_TOKEN }}
shell: bash
run: |
cd "${{ inputs.package_path }}"
org="$(jq '.name|split("/")|.[0]' package.json)"
if [[ $org == "\"@solana-program\"" ]] then
pnpm config set '//registry.npmjs.org/:_authToken' "${SOLANA_PROGRAM_NPM_TOKEN}"
elif [[ $org == "\"@solana\"" ]] then
pnpm config set '//registry.npmjs.org/:_authToken' "${SOLANA_NPM_TOKEN}"
else
echo "Unknown organization: $org"
exit 1
fi

- name: Set Git Author
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Publish
id: publish
run: ./scripts/publish-js.sh "${{ inputs.package_path }}" ${{ inputs.level }} ${{ inputs.tag }}

- name: Push Commit and Tag
run: git push origin --follow-tags

- name: Generate a changelog
if: github.event.inputs.create_release == 'true'
uses: orhun/git-cliff-action@v4
with:
config: "scripts/cliff.toml"
args: ${{ steps.publish.outputs.old_git_tag }}..HEAD --include-path "${{ inputs.package_path }}/**" --github-repo ${{ github.repository }}
env:
OUTPUT: TEMP_CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: Create GitHub release
if: github.event.inputs.create_release == 'true'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.publish.outputs.new_git_tag }}
bodyFile: TEMP_CHANGELOG.md
uses: solana-program/actions/.github/workflows/publish-js.yml@main
with:
sbpf-program-packages: "program confidential-elgamal-registry"
solana-cli-version: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }}
target: ${{ needs.set_env.outputs.TARGET }}
package-path: ${{ inputs.package-path }}
level: ${{ inputs.level }}
tag: ${{ inputs.tag }}
create-release: ${{ inputs.create-release }}
secrets: inherit
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ test-js-%:

generate-clients:
pnpm generate:clients

# Helpers for publishing
tag-name = $(lastword $(subst /, ,$(call make-path,$1)))
package-version = $(subst ",,$(shell jq -r '.version' $(call make-path,$1)/package.json))
preid-arg = $(subst pre,--preid $2,$(findstring pre,$1))

git-tag-js-%:
@echo "$(call tag-name,$*)@v$(call package-version,$*)"

publish-js-%:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous script was named publish-j% with the following comment:

# Make defaults % to .o if nothing is provided there, and then tries to build it
# as a C project, so we do something a bit hacky, and assume that any target
# starting with "j" is actually for "js".

Some of the other existing JS scripts still follow that convention. I think we should consider choosing the same naming convention for all JS scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point, I'll make them align better:

cd "$(call make-path,$*)" && pnpm install && pnpm version $(LEVEL) --no-git-tag-version $(call preid-arg,$(LEVEL),$(TAG)) && pnpm publish --no-git-checks --tag $(TAG)
42 changes: 0 additions & 42 deletions scripts/publish-js.sh

This file was deleted.