Skip to content

Commit b9419bb

Browse files
committed
Auto merge of #711 - AzureMarker:feature/skip-empty-versions, 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.
2 parents c6b4c72 + 04f6c0f commit b9419bb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

.github/workflows/publish.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ jobs:
3838
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
3939
shell: bash
4040
run: |
41+
# Check if we can skip releasing a new version
42+
# (there are no changes and the job was not manually triggered)
43+
export CHANGED=$(cargo workspaces changed --include-merged-tags --ignore-changes "**/Cargo.toml")
44+
if [[ -z "$CHANGED" && "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]]; then
45+
# Nothing has changed, so don't publish a new version
46+
exit 0
47+
fi
48+
4149
# Update version
4250
git config --global user.email "runner@gha.local"
4351
git config --global user.name "Github Action"

0 commit comments

Comments
 (0)