| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- 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
- - 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 "github-actions@github.com"
- 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 }}
- - 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 "github-actions@github.com"
- 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@v3
- 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
|