Skip to content

Commit

Permalink
Fix command typo (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr0id authored Sep 30, 2024
1 parent 2090cae commit b1debab
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,20 @@ jobs:
toolchain: stable
override: true

- name: Check if publication is necessary
id: check
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]] || [[ "${{ github.ref }}" == refs/heads/master ]]; then
echo "Publishing is necessary"
echo "publish=true" >> $GITHUB_OUTPUT
else
echo "Publishing is not necessary"
echo "publish=false" >> $GITHUB_OUTPUT
fi
- name: Publish to crates.io
if: steps.check.outputs.publish == 'true'
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# If it's a tag, publish as is
cargo publish
else
elif [[ "${{ github.ref }}" == refs/heads/master ]]; then
# If it's a push to master, publish as a pre-release version
VERSION=$(grep version Cargo.toml | sed -E 's/version = "(.*)"/\1/' | tr -d ' ')
VERSION=$(grep '^version =' Cargo.toml | sed -E 's/version = "(.*?)"/\1/')
COMMIT_HASH=$(git rev-parse --short HEAD)
NEW_VERSION="${VERSION}-pre.${COMMIT_HASH}"
sed -i "s/^version = .*/version = \"${NEW_VERSION}\"/" Cargo.toml
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" Cargo.toml
cargo publish --allow-dirty
fi
else
echo "Not publishing: not a push to master or a tag"
fi

0 comments on commit b1debab

Please sign in to comment.