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
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ runs:
if: ${{ inputs.rustfmt == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_FORMAT }}
toolchain: ${{ env.TOOLCHAIN_NIGHTLY }}
components: rustfmt

- name: Install Clippy
if: ${{ inputs.clippy == 'true' }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.TOOLCHAIN_LINT }}
toolchain: ${{ env.TOOLCHAIN_NIGHTLY }}
components: clippy

- name: Install Solana
Expand Down
25 changes: 4 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,6 @@ jobs:
- name: Run cargo-audit
run: pnpm rust:audit

semver_rust:
name: Check semver Rust
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-semver

- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-semver-checks

- name: Run semver checks
run: pnpm rust:semver

spellcheck_rust:
name: Spellcheck Rust
runs-on: ubuntu-latest
Expand Down Expand Up @@ -220,7 +200,10 @@ jobs:
path: ./**/*.so
key: ${{ runner.os }}-builds-${{ github.sha }}

- name: Test Client JS
- name: Build dependency
run: pnpm clients:js:build

- name: Test
run: pnpm clients:js-legacy:test

test_client_cli:
Expand Down
87 changes: 69 additions & 18 deletions .github/workflows/publish-js-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name: Publish JS Client
on:
workflow_dispatch:
inputs:
package_path:
description: Path to directory with package to release
required: true
default: 'clients/js'
type: choice
options:
- clients/js
- clients/js-legacy
level:
description: Version level
required: true
Expand All @@ -28,8 +36,8 @@ on:
default: true

jobs:
test_js:
name: Test JS client
test:
name: Test JS package
runs-on: ubuntu-latest
steps:
- name: Git Checkout
Expand All @@ -39,42 +47,71 @@ jobs:
uses: ./.github/actions/setup
with:
solana: true
cargo-cache-key: cargo-js-test-publish-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-js-test-publish

- name: Format
run: pnpm zx ./scripts/js/format.mjs "${{ inputs.package_path }}"

- name: Format JS Client
run: pnpm clients:js:format
- name: Lint
run: pnpm zx ./scripts/js/lint.mjs "${{ inputs.package_path }}"

- name: Lint JS Client
run: pnpm clients:js:lint
- name: Build Programs
run: pnpm programs:build

- name: Test JS Client
run: pnpm clients:js:test
- name: Test
run: pnpm zx ./scripts/js/test.mjs "${{ inputs.package_path }}"

publish_js:
name: Publish JS client
publish:
name: Publish JS package
runs-on: ubuntu-latest
needs: test_js
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: ./.github/actions/setup

- name: Ensure NPM_TOKEN variable is set
- 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.NPM_TOKEN }}
token: ${{ secrets.SOLANA_PROGRAM_NPM_TOKEN }}
if: ${{ env.token == '' }}
run: |
echo "The NPM_TOKEN secret variable is not set"
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
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
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: |
Expand All @@ -83,13 +120,27 @@ jobs:

- name: Publish JS Client
id: publish
run: pnpm clients:js:publish ${{ inputs.level }} ${{ inputs.tag }}
run: pnpm js:publish "${{ 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@v3
with:
config: "scripts/cliff.toml"
args: |
"${{ steps.publish.outputs.old_git_tag }}"..main
--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: js@v${{ steps.publish.outputs.new_version }}
tag: ${{ steps.publish.outputs.new_git_tag }}
bodyFile: TEMP_CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
name: Publish CLI
name: Publish Rust Crate

on:
workflow_dispatch:
inputs:
package_path:
description: Path to directory with package to release
required: true
default: 'clients/cli'
type: choice
options:
- clients/cli
- program
level:
description: Level
required: true
Expand All @@ -12,15 +20,6 @@ on:
- patch
- minor
- major
- rc
- beta
- alpha
- release
- version
version:
description: Version
required: false
type: string
dry_run:
description: Dry run
required: true
Expand All @@ -34,7 +33,7 @@ on:

jobs:
test:
name: Test
name: Test Rust Crate
runs-on: ubuntu-latest
steps:
- name: Git Checkout
Expand All @@ -43,45 +42,58 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-cli
clippy: true
rustfmt: true
solana: true
cargo-cache-key: cargo-test-publish-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-test-publish

- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-semver-checks

- name: Format
run: pnpm clients:cli:format
run: pnpm zx ./scripts/rust/format.mjs "${{ inputs.package_path }}"

- name: Lint
run: pnpm clients:cli:lint
run: pnpm zx ./scripts/rust/lint.mjs "${{ inputs.package_path }}"

- name: Build programs
run: pnpm programs:build

- name: Test
run: pnpm clients:cli:test
run: pnpm zx ./scripts/rust/test.mjs "${{ inputs.package_path }}"

publish_cli:
name: Publish CLI
- name: Check semver
run: pnpm rust:semver ${{ inputs.package_path }} --release-type ${{ inputs.level }}

publish:
name: Publish Rust Crate
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: ./.github/actions/setup
with:
cargo-cache-key: cargo-publish-cli
cargo-cache-fallback-key: cargo-cli
clippy: true
rustfmt: true
cargo-cache-key: cargo-publish-${{ inputs.package_path }}
cargo-cache-fallback-key: cargo-publish

- name: Install Cargo Release
run: which cargo-release || cargo install cargo-release

- name: Ensure CARGO_REGISTRY_TOKEN variable is set
env:
token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: ${{ env.token == '' }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: ${{ env.CARGO_REGISTRY_TOKEN == '' }}
run: |
echo "The CARGO_REGISTRY_TOKEN secret variable is not set"
echo "Go to \"Settings\" -> \"Secrets and variables\" -> \"Actions\" -> \"New repository secret\"."
Expand All @@ -92,31 +104,35 @@ jobs:
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Publish
- name: Publish Crate
id: publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ "${{ inputs.level }}" == "version" ]; then
LEVEL=${{ inputs.version }}
else
LEVEL=${{ inputs.level }}
fi

if [ "${{ inputs.dry_run }}" == "true" ]; then
OPTIONS="--dry-run"
else
OPTIONS=""
fi

pnpm clients:cli:publish $LEVEL $OPTIONS
pnpm rust:publish "${{ inputs.package_path }}" "${{ inputs.level }}" $OPTIONS

- name: Push Commit and Tag
if: github.event.inputs.dry_run != 'true'
run: git push origin --follow-tags
- name: Generate a changelog
if: github.event.inputs.create_release == 'true'
uses: orhun/git-cliff-action@v3
with:
config: "scripts/cliff.toml"
args: |
"${{ steps.publish.outputs.old_git_tag }}"..main
--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' && github.event.inputs.dry_run != 'true'
uses: ncipollo/release-action@v1
with:
tag: cli@v${{ steps.publish.outputs.new_version }}
tag: ${{ steps.publish.outputs.new_git_tag }}
bodyFile: TEMP_CHANGELOG.md
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ solana = "2.2.0"
# Specify Rust toolchains for rustfmt, clippy, and build.
# Any unprovided toolchains default to stable.
[workspace.metadata.toolchains]
format = "nightly-2024-11-22"
lint = "nightly-2024-11-22"
nightly = "nightly-2024-11-22"

[workspace.metadata.spellcheck]
config = "scripts/spellcheck.toml"

[workspace.metadata.release]
pre-release-commit-message = "Publish {{crate_name}} v{{version}}"
tag-message = "Publish {{crate_name}} v{{version}}"
consolidate-commits = false

[workspace.lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
Expand Down
1 change: 1 addition & 0 deletions clients/js-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
}
},
"scripts": {
"prepublishOnly": "pnpm build",
"clean": "rm -rf dist/*",
"build": "rm -rf dist/* && tsup && tsc -p ./tsconfig.declarations.json",
"build:program": "cargo build-sbf --manifest-path=../../program/Cargo.toml",
Expand Down
1 change: 1 addition & 0 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
},
"scripts": {
"prepublishOnly": "pnpm build",
"clean": "rm -fr dist/*",
"build": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./ts-fixup.sh",
"test": "tsc -p tsconfig.json",
Expand Down
Loading