name: CD
on:
release:
types:
- published
workflow_dispatch:
inputs:
dry_run:
description: 'Dry Run'
type: boolean
default: true
args:
description: 'Command Arguments'
required: false
type: string
default: ''
env:
CARGO_TERM_COLOR: always
jobs:
validate-release:
if: ${{ !contains(inputs.args, '--token') && github.ref_name == 'main' || github.event_name == 'release' }}
uses: ./.github/workflows/ci.yml
publish-release:
needs: validate-release
runs-on: ubuntu-latest
env:
ARGS: ${{ inputs.args }}
DRY_RUN: ${{ inputs.dry_run }}
RELEASE: ${{ github.event_name == 'release' }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Cargo Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-stable-
${{ runner.os }}-cargo-
${{ runner.os }}-
- name: Run Release
run: |
if $RELEASE == true; then
cargo publish --verbose
else
if $DRY_RUN == true; then
ARGS="$ARGS --dry-run"
fi
cargo publish $ARGS
fi