-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ci: ensure Cargo.toml and CHANGELOG of published crates are updated
#4620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8c31ec2
Lint manifest and changelog
thomaseizinger c4a297e
Fetch all refs
thomaseizinger e100d88
Use `--` to separate paths
thomaseizinger 3e66deb
Log some refs
thomaseizinger 538d3f6
Use 3 dots instead
thomaseizinger ac5d49b
Debugging
thomaseizinger 39e50d5
Run fast lints first
thomaseizinger 1b74683
Merge branch 'master' into feat/ci-for-manifest-and-changelog
thomaseizinger 770998d
Move lints to the bottom again
thomaseizinger 57e681d
Don't run if PRs are behind
thomaseizinger ea0bde9
Use merge base for diffing
thomaseizinger bd0f4d3
Update .github/workflows/ci.yml
thomaseizinger 45f0807
Update .github/workflows/ci.yml
thomaseizinger 3ad0a2b
Always lint for versions to be in sync
thomaseizinger 1f33913
Merge remote-tracking branch 'origin/feat/ci-for-manifest-and-changel…
thomaseizinger 2a68e08
Don't lint for unreleased versions if no code was touched
thomaseizinger 09e61c5
Merge branch 'master' into feat/ci-for-manifest-and-changelog
thomaseizinger bab661a
Merge branch 'master' into feat/ci-for-manifest-and-changelog
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -ex; | ||
|
|
||
| MANIFEST_PATH=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .manifest_path') | ||
| DIR_TO_CRATE=$(dirname "$MANIFEST_PATH") | ||
|
|
||
| MERGE_BASE=$(git merge-base "$HEAD_SHA" master) # Find the merge base. This ensures we only diff what was actually added in the PR. | ||
|
|
||
| DIFF_TO_MASTER=$(git diff "$HEAD_SHA".."$MERGE_BASE" --name-status -- "$DIR_TO_CRATE") | ||
| CHANGELOG_DIFF=$(git diff "$HEAD_SHA".."$MERGE_BASE" --name-only -- "$DIR_TO_CRATE/CHANGELOG.md") | ||
|
|
||
| VERSION_IN_CHANGELOG=$(awk -F' ' '/^## [0-9]+\.[0-9]+\.[0-9]+/{print $2; exit}' "$DIR_TO_CRATE/CHANGELOG.md") | ||
| VERSION_IN_MANIFEST=$(cargo metadata --format-version=1 --no-deps | jq -e -r '.packages[] | select(.name == "'"$CRATE"'") | .version') | ||
|
|
||
| # First, ensure version in Cargo.toml and CHANGELOG are in sync. This should always hold, regardless of whether the code in the crate was modified. | ||
| if [[ "$VERSION_IN_CHANGELOG" != "$VERSION_IN_MANIFEST" ]]; then | ||
| echo "Version in Cargo.toml ($VERSION_IN_MANIFEST) does not match version in CHANGELOG ($VERSION_IN_CHANGELOG)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # If the crate wasn't touched in this PR, exit early. | ||
| if [ -z "$DIFF_TO_MASTER" ]; then | ||
| exit 0; | ||
| fi | ||
|
|
||
| # Code was touched, ensure changelog is updated too. | ||
| if [ -z "$CHANGELOG_DIFF" ]; then | ||
| echo "Files in $DIR_TO_CRATE have changed, please write a changelog entry in $DIR_TO_CRATE/CHANGELOG.md" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Code was touched, ensure the version used in the manifest hasn't been released yet. | ||
mxinden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if git tag | grep -q "^$CRATE-v${VERSION_IN_MANIFEST}$"; then | ||
| echo "v$VERSION_IN_MANIFEST of '$CRATE' has already been released, please bump the version." | ||
thomaseizinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| exit 1 | ||
| fi | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.