Merge pull request #36 from 255doesnotexist/dependabot/cargo/serde_js… #6
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: | |
- main | |
paths: | |
- "Cargo.toml" | |
jobs: | |
publish: | |
runs-on: [self-hosted, linux] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
- name: Check for version changes | |
id: check_version | |
run: | | |
old_version=$(git show HEAD~1:Cargo.toml | grep '^version =' | sed 's/version = "\(.*\)"/\1/') | |
new_version=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/') | |
echo "Old version: $old_version" | |
echo "New version: $new_version" | |
if [ "$old_version" = "$new_version" ]; then | |
echo "Version has not changed. Skipping publish." | |
exit 0 | |
fi | |
- name: Publish to crates.io | |
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |