-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: add release workflow #19
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,87 @@ | ||
name: Prepare Release | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
level: | ||
description: 'Specify SemVer version level you wish to bump (see: https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md#bump-level)' | ||
required: true | ||
type: choice | ||
options: | ||
- release | ||
- patch | ||
- minor | ||
- major | ||
- alpha | ||
- beta | ||
- rc | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Rust version from rust-toolchain.toml | ||
run: rustup show | ||
|
||
- uses: cargo-bins/cargo-binstall@main | ||
|
||
- name: Install dependencies | ||
run: cargo binstall cargo-release -y | ||
|
||
- name: Set up git config | ||
run: | | ||
git config author.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | ||
git config author.name "${{ github.event.sender.login }}" | ||
git config committer.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config committer.name "GitHub Actions Bot" | ||
git config user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | ||
git config user.name "${{ github.event.sender.login }}" | ||
|
||
- name: Determine new version number by dry-running `cargo-release` | ||
run: | | ||
NEW_VERSION="$( | ||
cargo release version ${{ inputs.level }} 2>&1 \ | ||
| grep "Upgrading .* from .* to .*" \ | ||
| awk '{print $6}' \ | ||
)" | ||
echo "New version is $NEW_VERSION" | ||
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_ENV" | ||
|
||
- name: Switch to the release branch | ||
run: | | ||
BRANCH_NAME="release/v${{ env.NEW_VERSION }}" | ||
git switch -c "$BRANCH_NAME" | ||
|
||
- name: Roll changelog, bump version, and push branch | ||
run: | | ||
# see https://opensource.axo.dev/cargo-dist/book/workspaces/cargo-release-guide.html#using-cargo-release-with-pull-requests | ||
cargo release "${{ inputs.level }}" --execute --no-confirm --config prepare-release.toml | ||
|
||
- name: Open the release PR | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
TITLE="chore(release): prepare release ${{ env.NEW_VERSION }}" | ||
|
||
cat >BODY.md <<EOF | ||
This PR was automatically generated by this workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
|
||
After merging, run the following: | ||
|
||
'''bash | ||
git checkout main | ||
git pull | ||
cargo dist plan | ||
cargo release --execute | ||
''' | ||
EOF | ||
|
||
gh pr create --base main --title "$TITLE" --body-file BODY.md |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pre-release-replacements = [ | ||
{file="CHANGELOG.md", search="Unreleased", replace="{{version}}"}, | ||
{file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...v{{version}}", exactly=1}, | ||
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}"}, | ||
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n\n## [Unreleased] - ReleaseDate", exactly=1}, | ||
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/dfinity/dfxvm/compare/v{{version}}...HEAD", exactly=1}, | ||
] | ||
publish = false | ||
tag = false | ||
allow-branch = [ "release/v*" ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit of having a separate .toml file for release config over storing the configuration in root
Cargo.toml
?I also think that
release-prepare.toml
(vsprepare-release.toml
) is easier to find and mentally parse when eyeballing files in the repo, and conveys same msgThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benefit is that
cargo release
doesn't roll the changelogThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. The
--config
points to a file that has changelog rolling configured.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you mean calling
cargo release --execute
as last step of the process (as mentioned in contributing.md) has a different behavior. If that's the case, then I find it confusing or at least, not very obviousThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the GH workflow runs
cargo release ... --config prepare-release.yml
, it needs to roll the changelog, so that that goes in the PR.After the PR is merged, the
cargo release --execute
final step should not roll the changelog (which would create an additional commit).