Skip to content
Open
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
37 changes: 25 additions & 12 deletions .github/workflows/publish-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,32 @@ jobs:
with:
pnpm: true
solana: ${{ inputs.solana-cli-version }}
cargo-cache-key: cargo-publish-js-test-${{ inputs.package-path }}
cargo-cache-fallback-key: cargo-publish-js-test
cache: false

- name: Format
run: make format-check-js-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "format-check-js-${TARGET}"

- name: Lint
run: make lint-js-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "lint-js-${TARGET}"

- name: Build programs
shell: bash
env:
SBPF_PROGRAM_PACKAGES: ${{ inputs.sbpf-program-packages }}
run: |
for program in ${{ inputs.sbpf-program-packages }}
for program in $SBPF_PROGRAM_PACKAGES
do
make build-sbf-$program
make "build-sbf-${program}"
done

- name: Test
run: make test-js-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "test-js-${TARGET}"

- name: Write check summary
shell: bash
Expand Down Expand Up @@ -115,6 +122,7 @@ jobs:
uses: solana-program/actions/setup-ubuntu@main
with:
pnpm: true
cache: false

- name: Set Git Author
env:
Expand All @@ -128,17 +136,22 @@ jobs:
id: publish
env:
NPM_CONFIG_PROVENANCE: "true"
LEVEL: ${{ inputs.level }}
TAG: ${{ inputs.tag }}
TARGET: ${{ inputs.target }}
shell: bash
run: |
echo "old_git_tag=$(make git-tag-js-${{ inputs.target }})" >> "${GITHUB_OUTPUT}"
LEVEL=${{ inputs.level }} TAG=${{ inputs.tag }} make publish-js-${{ inputs.target }}
echo "new_git_tag=$(make git-tag-js-${{ inputs.target }})" >> "${GITHUB_OUTPUT}"
echo "old_git_tag=$(make "git-tag-js-${TARGET}")" >> "${GITHUB_OUTPUT}"
LEVEL="$LEVEL" TAG="$TAG" make "publish-js-${TARGET}"
echo "new_git_tag=$(make "git-tag-js-${TARGET}")" >> "${GITHUB_OUTPUT}"

- name: Git Commit Bump, Tag, and Push
shell: bash
env:
NEW_GIT_TAG: ${{ steps.publish.outputs.new_git_tag }}
run: |
git commit -am "Publish ${{ steps.publish.outputs.new_git_tag }}"
git tag -a "${{ steps.publish.outputs.new_git_tag }}" -m "Publish ${{ steps.publish.outputs.new_git_tag }}"
git commit -am "Publish ${NEW_GIT_TAG}"
git tag -a "${NEW_GIT_TAG}" -m "Publish ${NEW_GIT_TAG}"
git push origin --follow-tags

- name: Generate a changelog
Expand Down
69 changes: 42 additions & 27 deletions .github/workflows/publish-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,32 @@ jobs:
solana: ${{ inputs.solana-cli-version }}
cli: true
purge: true
cargo-cache-key: cargo-test-publish-${{ inputs.package-path }}
cargo-cache-fallback-key: cargo-test-publish
cache: false

- name: Format
run: make format-check-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "format-check-${TARGET}"

- name: Clippy
run: make clippy-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "clippy-${TARGET}"

- name: Build programs
shell: bash
env:
SBPF_PROGRAM_PACKAGES: ${{ inputs.sbpf-program-packages }}
run: |
for program in ${{ inputs.sbpf-program-packages }}
for program in $SBPF_PROGRAM_PACKAGES
do
make build-sbf-$program
make "build-sbf-${program}"
done

- name: Test
run: make test-${{ inputs.target }}
env:
TARGET: ${{ inputs.target }}
run: make "test-${TARGET}"

semver:
name: Check Semver
Expand All @@ -97,8 +104,7 @@ jobs:
uses: solana-program/actions/setup-ubuntu@main
with:
cli: true
cargo-cache-key: cargo-publish-semver-${{ inputs.package-path }}
cargo-cache-fallback-key: cargo-publish-semver
cache: false

- name: Install cargo-semver-checks
uses: taiki-e/install-action@v2
Expand All @@ -108,9 +114,11 @@ jobs:
- name: Check if crate has a lib target
id: has_lib
shell: bash
env:
PACKAGE_PATH: ${{ inputs.package-path }}
run: |
set +e # toml crashes the whole shell if it fails to find the key
result=$(toml get "${{ inputs.package-path }}/Cargo.toml" lib.crate-type)
result=$(toml get "${PACKAGE_PATH}/Cargo.toml" lib.crate-type)
if [[ "$result" == *"lib"* ]]; then
echo "has_lib=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -123,13 +131,15 @@ jobs:
git config --global user.name "github-actions[bot]"

- name: Set Version
env:
LEVEL: ${{ inputs.level }}
VERSION: ${{ inputs.version }}
PACKAGE_PATH: ${{ inputs.package-path }}
run: |
if [ "${{ inputs.level }}" == "version" ]; then
LEVEL=${{ inputs.version }}
else
LEVEL=${{ inputs.level }}
if [ "$LEVEL" == "version" ]; then
LEVEL="$VERSION"
fi
cargo release $LEVEL --manifest-path "${{ inputs.package-path }}/Cargo.toml" --no-tag --no-publish --no-push --no-confirm --execute
cargo release "$LEVEL" --manifest-path "${PACKAGE_PATH}/Cargo.toml" --no-tag --no-publish --no-push --no-confirm --execute

- name: Write check summary
shell: bash
Expand Down Expand Up @@ -157,7 +167,9 @@ jobs:

- name: Check semver
if: ${{ steps.has_lib.outputs.has_lib == 'true' && inputs.run-semver }}
run: cargo semver-checks --manifest-path "${{ inputs.package-path }}/Cargo.toml"
env:
PACKAGE_PATH: ${{ inputs.package-path }}
run: cargo semver-checks --manifest-path "${PACKAGE_PATH}/Cargo.toml"
Comment on lines +170 to +172

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For my own information, what exactly does the env variable provide in a case like this? The variable is already quoted, so it should end up exactly the same, no?


publish:
name: Publish Rust Crate
Expand Down Expand Up @@ -187,8 +199,7 @@ jobs:
uses: solana-program/actions/setup-ubuntu@main
with:
cli: true
cargo-cache-key: cargo-publish-${{ inputs.package-path }}
cargo-cache-fallback-key: cargo-publish
cache: false

- name: Install cargo-release and toml-cli
uses: taiki-e/install-action@v2
Expand All @@ -210,26 +221,30 @@ jobs:
id: publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
LEVEL: ${{ inputs.level }}
VERSION: ${{ inputs.version }}
DRY_RUN: ${{ inputs.dry-run }}
TARGET: ${{ inputs.target }}
run: |
if [ "${{ inputs.level }}" == "version" ]; then
LEVEL=${{ inputs.version }}
else
LEVEL=${{ inputs.level }}
if [ "$LEVEL" == "version" ]; then
LEVEL="$VERSION"
fi

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

echo "old_git_tag=$(make git-tag-rust-${{ inputs.target }})" >> "${GITHUB_OUTPUT}"
LEVEL=${LEVEL} make publish-rust-${OPTIONS}${{ inputs.target }}
echo "new_git_tag=$(make git-tag-rust-${{ inputs.target }})" >> "${GITHUB_OUTPUT}"
echo "old_git_tag=$(make "git-tag-rust-${TARGET}")" >> "${GITHUB_OUTPUT}"
LEVEL="$LEVEL" make "publish-rust-${OPTIONS}${TARGET}"
echo "new_git_tag=$(make "git-tag-rust-${TARGET}")" >> "${GITHUB_OUTPUT}"

- name: Package crate for attestation
if: ${{ inputs.dry-run == false }}
run: cargo package --no-verify --manifest-path "${{ inputs.package-path }}/Cargo.toml"
env:
PACKAGE_PATH: ${{ inputs.package-path }}
run: cargo package --no-verify --manifest-path "${PACKAGE_PATH}/Cargo.toml"

- name: Generate SLSA provenance
if: ${{ inputs.dry-run == false }}
Expand Down
14 changes: 9 additions & 5 deletions setup-ubuntu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
cli:
description: Install CLI dependencies if `true`. Defaults to `false`.
required: false
cache:
description: Enable dependency caching (pnpm, Solana, cargo) if `true`. Defaults to `true`.
required: false
default: 'true'
purge:
description: Purge unused directories if `true`. Defaults to `false`.
required: false
Expand Down Expand Up @@ -70,7 +74,7 @@ runs:
uses: actions/setup-node@v6
with:
node-version: 24
cache: 'pnpm'
cache: ${{ inputs.cache == 'true' && 'pnpm' || '' }}

- name: Install Dependencies
if: ${{ inputs.pnpm == 'true' }}
Expand Down Expand Up @@ -144,7 +148,7 @@ runs:
uses: solana-program/actions/install-solana@v1
with:
version: ${{ inputs.solana }}
cache: true
cache: ${{ inputs.cache }}

- name: Install CLI dependencies
if: ${{ inputs.cli == 'true' }}
Expand All @@ -167,7 +171,7 @@ runs:
run: cargo +"${{ inputs.nightly-toolchain }}" miri setup

- name: Cache Cargo Dependencies
if: ${{ inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
if: ${{ inputs.cache == 'true' && inputs.cargo-cache-key && !inputs.cargo-cache-fallback-key }}
uses: actions/cache@v5
with:
path: |
Expand All @@ -180,7 +184,7 @@ runs:
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-key }}

- name: Cache Cargo Dependencies With Fallback
if: ${{ inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
if: ${{ inputs.cache == 'true' && inputs.cargo-cache-key && inputs.cargo-cache-fallback-key }}
uses: actions/cache@v5
with:
path: |
Expand All @@ -196,7 +200,7 @@ runs:
${{ runner.os }}-${{ inputs.cargo-cache-fallback-key }}

- name: Cache Local Cargo Dependencies
if: ${{ inputs.cargo-cache-local-key }}
if: ${{ inputs.cache == 'true' && inputs.cargo-cache-local-key }}
uses: actions/cache@v5
with:
path: |
Expand Down