Skip to content

Publish

Publish #93

Workflow file for this run

name: Publish
on:
workflow_dispatch:
inputs:
crate:
description: Crate
required: true
default: sdk/pinocchio
type: choice
options:
- programs/associated-token-account
- programs/memo
- programs/system
- programs/token
- sdk/log/crate
- sdk/log/macro
- sdk/pinocchio
- sdk/pubkey
level:
description: Level
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- rc
- beta
- alpha
- release
- version
version:
description: Version (used with level "version")
required: false
type: string
dry_run:
description: Dry run
required: true
default: true
type: boolean
create_release:
description: Create a GitHub release
required: true
type: boolean
default: true
env:
CACHE: true
jobs:
semver_check:
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-semver-checks
toolchain: test
components: release, semver-checks
- name: Set Version
run: |
if [ "${{ inputs.level }}" == "version" ]; then
LEVEL=${{ inputs.version }}
else
LEVEL=${{ inputs.level }}
fi
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
cargo release $LEVEL --manifest-path ${{ inputs.crate }}/Cargo.toml --no-tag --no-publish --no-push --no-confirm --execute
- name: Check semver
run: |
pnpm semver ${{ inputs.crate }}
publish_release:
name: Publish
runs-on: ubuntu-latest
needs: semver_check
permissions:
contents: write
steps:
- name: Ensure CARGO_REGISTRY_TOKEN variable is set
env:
token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: ${{ env.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: 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
toolchain: test
components: release
solana: true
- name: Build
run: pnpm build-sbf ${{ inputs.crate }}
- name: Test
run: pnpm test ${{ inputs.crate }}
- name: Set Git Author
run: |
git config --global user.email "[email protected]"
git config --global user.name "github-actions"
- 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 tsx ./scripts/publish.mts ${{ inputs.crate }} $LEVEL $OPTIONS
- name: Generate a changelog
if: github.event.inputs.dry_run != 'true' && github.event.inputs.create_release == 'true'
uses: orhun/git-cliff-action@v4
with:
config: ".github/cliff.toml"
args: |
"${{ steps.publish.outputs.old_git_tag }}"..main
--include-path "${{ inputs.crate }}/**"
--github-repo "${{ github.repository }}"
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Create GitHub release
if: github.event.inputs.dry_run != 'true' && github.event.inputs.create_release == 'true'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.publish.outputs.new_git_tag }}
bodyFile: CHANGELOG.md