Skip to content

Commit

Permalink
Auto merge of rust-lang#711 - AzureMarker:feature/skip-empty-versions…
Browse files Browse the repository at this point in the history
…, r=jackh726

Skip crate publishing if there have been no changes

The last few crate releases have not introduced any changes, but the weekly publishing job has still pumped out new versions:
![image](https://user-images.githubusercontent.com/4417660/120943604-f2f37880-c6fd-11eb-8034-662830f950a8.png)

Now, using the [`cargo workspaces changed`](https://github.com/pksunkara/cargo-workspaces#changed) command, new crate versions are only published if there has been a change in one of the crates.

One interesting effect of using this method is that changes to sections of the project such as the book or main readme (which do not affect the crates) do not trigger crate releases. I don't expect that this will be an issue, but it's important to note.

Edit: I've updated the code to skip the empty release check if the job is manually triggered. This should be a sufficient workaround.
  • Loading branch information
bors committed Jun 9, 2021
2 parents c6b4c72 + 04f6c0f commit b9419bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ jobs:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
shell: bash
run: |
# Check if we can skip releasing a new version
# (there are no changes and the job was not manually triggered)
export CHANGED=$(cargo workspaces changed --include-merged-tags --ignore-changes "**/Cargo.toml")
if [[ -z "$CHANGED" && "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]]; then
# Nothing has changed, so don't publish a new version
exit 0
fi
# Update version
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
Expand Down

0 comments on commit b9419bb

Please sign in to comment.