Skip to content

Commit

Permalink
Update publish.yml
Browse files Browse the repository at this point in the history
Simplfy action
  • Loading branch information
mdr0id authored Sep 30, 2024
1 parent f200477 commit c40b148
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,22 @@ name: Publish to crates.io
on:
push:
branches:
- master
- master # Trigger on push to master branch
tags:
- 'v*'
- 'v*' # Trigger when any tag is pushed

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3

- 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
run: cargo publish --allow-dirty --token ${{ secrets.CRATES_IO_TOKEN }}

0 comments on commit c40b148

Please sign in to comment.