Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit ba05751

Browse files
authored
ci: Add git tag / commit message with cargo release (#7235)
#### Problem The publish workflow is great, but it does some work by hand, namely creating the git commit and tag. `cargo release` can do this, but we currently don't use it because we aren't customizing it. #### Summary of changes Add configuration options to the top-level Cargo.toml and let cargo release do everything for us.
1 parent dab04d4 commit ba05751

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

.github/workflows/publish-rust.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ jobs:
205205
206206
./ci/publish-rust.sh "${{ inputs.package_path }}" $LEVEL $OPTIONS
207207
208-
- name: Push Commit and Tag
209-
if: github.event.inputs.dry_run != 'true'
210-
run: git push origin --follow-tags
211-
212208
- name: Generate a changelog
213209
if: github.event.inputs.create_release == 'true'
214210
uses: orhun/git-cliff-action@v3

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,8 @@ exclude = [
8585
]
8686

8787
resolver = "2"
88+
89+
[workspace.metadata.release]
90+
pre-release-commit-message = "Publish {{crate_name}} v{{version}}"
91+
tag-message = "Publish {{crate_name}} v{{version}}"
92+
consolidate-commits = false

ci/publish-rust.sh

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ cd "${PACKAGE_PATH}"
2222

2323
# Get the old version, used with git-cliff
2424
old_version=$(readCargoVariable version "Cargo.toml")
25+
package_name=$(readCargoVariable name "Cargo.toml")
26+
tag_name="$(echo $package_name | sed 's/spl-//')"
2527

26-
# Publish the new version.
28+
# Publish the new version, commit the repo change, tag it, and push it all.
2729
if [[ -n ${DRY_RUN} ]]; then
2830
cargo release ${LEVEL}
2931
else
30-
cargo release ${LEVEL} --no-push --no-tag --no-confirm --execute
32+
cargo release ${LEVEL} --tag-name "${tag_name}-v{{version}}" --no-confirm --execute
3133
fi
3234

3335
# Stop here if this is a dry run.
@@ -37,8 +39,6 @@ fi
3739

3840
# Get the new version.
3941
new_version=$(readCargoVariable version "Cargo.toml")
40-
package_name=$(readCargoVariable name "Cargo.toml")
41-
tag_name="$(echo $package_name | sed 's/spl-//')"
4242
new_git_tag="${tag_name}-v${new_version}"
4343
old_git_tag="${tag_name}-v${old_version}"
4444
release_title="SPL ${tag_name} - v${new_version}"
@@ -49,12 +49,3 @@ if [[ -n $CI ]]; then
4949
echo "old_git_tag=${old_git_tag}" >> $GITHUB_OUTPUT
5050
echo "release_title=${release_title}" >> $GITHUB_OUTPUT
5151
fi
52-
53-
# Soft reset the last commit so we can create our own commit and tag.
54-
git reset --soft HEAD~1
55-
56-
# Commit the new version.
57-
git commit -am "Publish ${tag_name} v${new_version}"
58-
59-
# Tag the new version.
60-
git tag -a ${new_git_tag} -m "${tag_name} v${new_version}"

0 commit comments

Comments
 (0)