Update publish.yml #14
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 to crates.io | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Debug Token | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: | | |
if [ -n "$CRATES_IO_TOKEN" ]; then | |
echo "CRATES_IO_TOKEN is set" | |
echo "CRATES_IO_TOKEN length: ${#CRATES_IO_TOKEN}" | |
else | |
echo "CRATES_IO_TOKEN is not set" | |
fi | |
- name: Publish to crates.io | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
run: | | |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then | |
echo "CARGO_REGISTRY_TOKEN is not set. Cannot publish." | |
exit 1 | |
fi | |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
cargo publish --token ${CARGO_REGISTRY_TOKEN} || cargo publish --token ${CARGO_REGISTRY_TOKEN} --verbose | |
elif [[ "${{ github.ref }}" == refs/heads/master ]]; then | |
cargo publish --token ${CARGO_REGISTRY_TOKEN} --allow-dirty || cargo publish --token ${CARGO_REGISTRY_TOKEN} --allow-dirty --verbose | |
else | |
echo "Not publishing: not a push to master or a tag" | |
fi |