|
|
@@ -3,7 +3,7 @@ name: Publish Rust Crate
|
|
|
on:
|
|
|
workflow_dispatch:
|
|
|
inputs:
|
|
|
- package_path:
|
|
|
+ package-path:
|
|
|
description: Path to directory with package to release
|
|
|
required: true
|
|
|
default: 'interface'
|
|
|
@@ -29,151 +29,50 @@ on:
|
|
|
description: Version (used with level "version")
|
|
|
required: false
|
|
|
type: string
|
|
|
- dry_run:
|
|
|
+ dry-run:
|
|
|
description: Dry run
|
|
|
required: true
|
|
|
default: true
|
|
|
type: boolean
|
|
|
- create_release:
|
|
|
+ create-release:
|
|
|
description: Create a GitHub release
|
|
|
required: true
|
|
|
type: boolean
|
|
|
default: true
|
|
|
|
|
|
jobs:
|
|
|
- test:
|
|
|
- name: Test Rust Crate
|
|
|
+ set_env:
|
|
|
+ name: Set variables to be used in strategy definitions
|
|
|
runs-on: ubuntu-latest
|
|
|
+ outputs:
|
|
|
+ RUST_TOOLCHAIN_NIGHTLY: ${{ steps.compute.outputs.RUST_TOOLCHAIN_NIGHTLY }}
|
|
|
+ SOLANA_CLI_VERSION: ${{ steps.compute.outputs.SOLANA_CLI_VERSION }}
|
|
|
+ TARGET: ${{ steps.compute.outputs.TARGET }}
|
|
|
steps:
|
|
|
- name: Git Checkout
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
- - name: Setup Environment
|
|
|
- uses: ./.github/actions/setup
|
|
|
- with:
|
|
|
- clippy: true
|
|
|
- rustfmt: true
|
|
|
- solana: true
|
|
|
- cargo-cache-key: cargo-test-publish-${{ inputs.package_path }}
|
|
|
- cargo-cache-fallback-key: cargo-test-publish
|
|
|
-
|
|
|
- - name: Format
|
|
|
- run: pnpm zx ./scripts/rust/format.mjs "${{ inputs.package_path }}"
|
|
|
-
|
|
|
- - name: Lint
|
|
|
- run: pnpm zx ./scripts/rust/lint.mjs "${{ inputs.package_path }}"
|
|
|
-
|
|
|
- - name: Build programs
|
|
|
- run: pnpm programs:build
|
|
|
-
|
|
|
- - name: Test
|
|
|
- run: pnpm zx ./scripts/rust/test.mjs "${{ inputs.package_path }}"
|
|
|
-
|
|
|
- semver:
|
|
|
- name: Check Semver
|
|
|
- runs-on: ubuntu-latest
|
|
|
- steps:
|
|
|
- - name: Git checkout
|
|
|
- uses: actions/checkout@v4
|
|
|
-
|
|
|
- - name: Setup Environment
|
|
|
- uses: ./.github/actions/setup
|
|
|
- with:
|
|
|
- cargo-cache-key: cargo-publish-semver-${{ inputs.package_path }}
|
|
|
- cargo-cache-fallback-key: cargo-publish-semver
|
|
|
-
|
|
|
- - name: Install cargo-semver-checks
|
|
|
- uses: taiki-e/install-action@v2
|
|
|
- with:
|
|
|
- tool: cargo-semver-checks@0.42.0,cargo-release@0.25.18
|
|
|
-
|
|
|
- - name: Set Git Author (required for cargo-release)
|
|
|
- run: |
|
|
|
- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
- git config --global user.name "github-actions[bot]"
|
|
|
-
|
|
|
- - name: Set Version
|
|
|
+ - name: Compute variables
|
|
|
+ id: compute
|
|
|
+ shell: bash
|
|
|
run: |
|
|
|
- if [ "${{ inputs.level }}" == "version" ]; then
|
|
|
- LEVEL=${{ inputs.version }}
|
|
|
- else
|
|
|
- LEVEL=${{ inputs.level }}
|
|
|
- fi
|
|
|
- cargo release $LEVEL --manifest-path "${{ inputs.package_path }}/Cargo.toml" --no-tag --no-publish --no-push --no-confirm --execute
|
|
|
-
|
|
|
- - name: Check semver
|
|
|
- run: pnpm rust:semver --manifest-path "${{ inputs.package_path }}/Cargo.toml"
|
|
|
-
|
|
|
- publish:
|
|
|
- name: Publish Rust Crate
|
|
|
- runs-on: ubuntu-latest
|
|
|
- needs: [test, semver]
|
|
|
- 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-${{ inputs.package_path }}
|
|
|
- cargo-cache-fallback-key: cargo-publish
|
|
|
-
|
|
|
- - name: Install cargo-release
|
|
|
- uses: taiki-e/install-action@v2
|
|
|
- with:
|
|
|
- tool: cargo-release@0.25.18
|
|
|
-
|
|
|
- - name: Ensure CARGO_REGISTRY_TOKEN variable is set
|
|
|
- env:
|
|
|
- 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\"."
|
|
|
- exit 1
|
|
|
-
|
|
|
- - 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 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 rust:publish "${{ inputs.package_path }}" $LEVEL $OPTIONS
|
|
|
-
|
|
|
- - 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' && github.event.inputs.dry_run != 'true'
|
|
|
- uses: ncipollo/release-action@v1
|
|
|
- with:
|
|
|
- tag: ${{ steps.publish.outputs.new_git_tag }}
|
|
|
- bodyFile: TEMP_CHANGELOG.md
|
|
|
+ echo "RUST_TOOLCHAIN_NIGHTLY=$(make rust-toolchain-nightly)" >> "$GITHUB_OUTPUT"
|
|
|
+ echo "SOLANA_CLI_VERSION=$(make solana-cli-version)" >> "$GITHUB_OUTPUT"
|
|
|
+ TARGET=$(echo ${{ inputs.package-path }} | sed 's#/#-#')
|
|
|
+ echo "TARGET=$TARGET" >> "$GITHUB_OUTPUT"
|
|
|
+
|
|
|
+ main:
|
|
|
+ needs: set_env
|
|
|
+ uses: solana-program/actions/.github/workflows/publish-rust.yml@main
|
|
|
+ with:
|
|
|
+ sbpf-program-packages: "program"
|
|
|
+ solana-cli-version: ${{ needs.set_env.outputs.SOLANA_CLI_VERSION }}
|
|
|
+ clippy-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }}
|
|
|
+ rustfmt-toolchain: ${{ needs.set_env.outputs.RUST_TOOLCHAIN_NIGHTLY }}
|
|
|
+ target: ${{ needs.set_env.outputs.TARGET }}
|
|
|
+ package-path: ${{ inputs.package-path }}
|
|
|
+ level: ${{ inputs.level }}
|
|
|
+ version: ${{ inputs.version }}
|
|
|
+ create-release: ${{ inputs.create-release }}
|
|
|
+ dry-run: ${{ inputs.dry-run }}
|
|
|
+ secrets: inherit
|