Skip to content

Update publish.yml

Update publish.yml #8

Workflow file for this run

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: Update Cargo.toml
run: |
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: Debug Token
run: |
echo "CRATES_IO_TOKEN is set: ${{ secrets.CRATES_IO_TOKEN != '' }}"
echo "CRATES_IO_TOKEN length: ${#CRATES_IO_TOKEN}"
echo "CARGO_REGISTRY_TOKEN is set: ${{ env.CARGO_REGISTRY_TOKEN != '' }}"
echo "CARGO_REGISTRY_TOKEN length: ${#CARGO_REGISTRY_TOKEN}"
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
echo "CARGO_REGISTRY_TOKEN length in publish step: ${#CARGO_REGISTRY_TOKEN}"
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