Publish Crate #6
This file contains hidden or 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 Crate | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| level: | |
| description: Level | |
| required: true | |
| default: patch | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - rc | |
| - beta | |
| - alpha | |
| - release | |
| - version | |
| version: | |
| description: Version | |
| required: false | |
| type: string | |
| dry_run: | |
| description: Dry run | |
| required: true | |
| default: true | |
| type: boolean | |
| env: | |
| CACHE: true | |
| jobs: | |
| build: | |
| name: Build | |
| uses: ./.github/workflows/build.yml | |
| secrets: inherit | |
| test: | |
| name: Test | |
| needs: build | |
| uses: ./.github/workflows/test.yml | |
| secrets: inherit | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.SVC_TOKEN }} | |
| - name: Install Rust | |
| uses: metaplex-foundation/actions/install-rust@v1 | |
| with: | |
| toolchain: "1.85.0" | |
| - name: Install cargo-release | |
| uses: metaplex-foundation/actions/install-cargo-release@v1 | |
| with: | |
| cache: ${{ env.CACHE }} | |
| - name: Load environment variables | |
| run: cat .github/.env >> $GITHUB_ENV | |
| - name: Publish | |
| run: | | |
| if [ "${{ inputs.level }}" == "version" ]; then | |
| BUMP=${{ inputs.version }} | |
| else | |
| BUMP=${{ inputs.level }} | |
| fi | |
| if [ "${{ inputs.dry_run }}" == "false" ]; then | |
| OPTIONS="--no-push --no-tag --no-confirm --execute" | |
| git config user.name ${{ env.COMMIT_USER_NAME }} | |
| git config user.email ${{ env.COMMIT_USER_EMAIL }} | |
| fi | |
| cargo login ${{ secrets.CRATES_TOKEN }} | |
| cargo release $BUMP $OPTIONS | |
| if [ "${{ inputs.dry_run }}" == "false" ]; then | |
| git reset --soft HEAD~1 | |
| fi | |
| CRATE_VERSION=`grep -E '^version\s*=' Cargo.toml | awk -F '"' '{print $2}'` | |
| echo CRATE_VERSION="${CRATE_VERSION}" >> $GITHUB_ENV | |
| - name: Commit and tag new version | |
| uses: stefanzweifel/git-auto-commit-action@v4 | |
| if: github.event.inputs.dry_run == 'false' | |
| with: | |
| commit_message: "chore: Release podded version ${{ env.CRATE_VERSION }}" | |
| tagging_message: podded@v${{ env.CRATE_VERSION }} |