Publish #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
crate: | |
description: Crate | |
required: true | |
default: sdk/pinocchio | |
type: choice | |
options: | |
- programs/associated-token-account | |
- 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 | |
- version | |
version: | |
description: 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: | |
publish_release: | |
name: Publish | |
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 | |
toolchain: test | |
- name: Install cargo-set-version | |
run: which cargo-set-version || cargo install cargo-set-version | |
- name: Install cargo-semver-checks | |
run: which cargo-semver-checks || cargo install cargo-semver-checks | |
- name: Test | |
run: pnpm test ${{ inputs.crate }} | |
- 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: Set Git Author | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "github-actions" | |
- name: Check semver | |
run: | | |
SET_VERSION_ARGS="--bump" | |
LEVEL=${{ inputs.level }} | |
if [ "${{ inputs.level }}" == "version" ]; then | |
SET_VERSION_ARGS="" | |
LEVEL=${{ inputs.version }} | |
fi | |
# Bump the version to validate the semver (this will be restored later) | |
pnpm set-version ${{ inputs.crate }} $SET_VERSION_ARGS $LEVEL | |
# Check the semver | |
pnpm semver ${{ inputs.crate }} --release-type ${{ inputs.level }} | |
# Restore the original Cargo.toml | |
git restore . | |
echo BUMP="${LEVEL}" >> $GITHUB_ENV | |
- name: Publish Crate | |
id: publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: | | |
if [ "${{ inputs.dry_run }}" == "true" ]; then | |
OPTIONS="--dry-run" | |
else | |
OPTIONS="" | |
fi | |
pnpm tsx ./scripts/publish.mts ${{ inputs.crate }} ${{ env.BUMP }} $OPTIONS | |
- name: Push Commit and Tag | |
if: github.event.inputs.dry_run != 'true' | |
run: git push origin --follow-tags | |
- 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.crate }}@v${{ steps.publish.outputs.version }} |