Publish to crates.io #1
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: | |
workflow_run: | |
workflows: ["Continuous Integration"] | |
types: | |
- completed | |
jobs: | |
publish: | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Check for changes in src directory | |
id: check_changes | |
run: | | |
if git diff --name-only ${{ github.event.workflow_run.head_commit.id }}^ ${{ github.event.workflow_run.head_commit.id }} | grep -q '^src/'; then | |
echo "changes_in_src=true" >> $GITHUB_ENV | |
else | |
echo "changes_in_src=false" >> $GITHUB_ENV | |
fi | |
- name: Publish to crates.io | |
if: env.changes_in_src == 'true' | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: cargo publish |