Skip to content

Commit

Permalink
Update publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr0id authored Sep 30, 2024
1 parent 1870409 commit c77f3e6
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,30 @@ jobs:
toolchain: stable
override: true

- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Update Cargo.toml
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# If it's a tag, publish as is
cargo publish
elif [[ "${{ github.ref }}" == refs/heads/master ]]; then
# If it's a push to master, publish as a pre-release version
if [[ "${{ github.ref }}" == refs/heads/master ]]; then
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
# Add missing metadata
sed -i '/^version = / a description = "Jito's Rust RPC Library"' Cargo.toml
sed -i '/^description = / a license = "MIT"' Cargo.toml
sed -i '/^license = / a repository = "https://github.com/jito-labs/jito-rust-rpc"' Cargo.toml
fi
cat Cargo.toml
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
echo "CARGO_REGISTRY_TOKEN length: ${#CARGO_REGISTRY_TOKEN}"
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
cargo publish --token "${CARGO_REGISTRY_TOKEN}"
elif [[ "${{ github.ref }}" == refs/heads/master ]]; then
cargo publish --token "${CARGO_REGISTRY_TOKEN}" --allow-dirty
else
echo "Not publishing: not a push to master or a tag"
fi

0 comments on commit c77f3e6

Please sign in to comment.