Skip to content
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

Can PrepareRelease and Release be in different workflows? #1267

Open
BatmanAoD opened this issue Dec 13, 2024 · 2 comments
Open

Can PrepareRelease and Release be in different workflows? #1267

BatmanAoD opened this issue Dec 13, 2024 · 2 comments

Comments

@BatmanAoD
Copy link
Collaborator

You've previously mentioned that you wanted to be able to split the preparation workflow from the release workflow, so that they could be run as two separate steps. I thought that work was already done, but now I can't find where you referred to it.

It appears that this mostly works, but git tags are not created. Is that the expected behavior for now?

@dbanty
Copy link
Member

dbanty commented Dec 13, 2024

It definitely should work, but I think I've mostly used it with GitHub releases like this example so maybe there's something broken with tags 🤔

@BatmanAoD
Copy link
Collaborator Author

BatmanAoD commented Dec 13, 2024

Putting the workflow back in one step worked. Just in case this is due to me screwing something up, here's the non-working Knope.toml:

[package]
versioned_files = ["python-grpc/pyproject.toml", "python-grpc-betterproto/pyproject.toml", "rust/Cargo.toml", "golang/go.mod"]

[[workflows]]
name = "prepare"

[[workflows.steps]]
type = "PrepareRelease"
allow_empty = true

[[workflows.steps]]
type = "Command"
# Knope feature request to make this behavior automatic:
# https://github.com/knope-dev/knope/issues/162
command = "cargo update -w --manifest-path rust/Cargo.toml"

[[workflows]]
name = "release"

# Needed so that `prepare` and `release` can run in separate CI steps
[[workflows.steps]]
type = "Command"
command = "git add python-grpc/pyproject.toml python-grpc-betterproto/pyproject.toml rust/Cargo.toml rust/Cargo.lock golang/go.mod"

[[workflows.steps]]
type = "Command"
command = "git commit -m \"chore: prepare release $version\""

[workflows.steps.variables]
# `Version` is a "magic" Knope string that will be replaced with the actual version
"$version" = "Version"

[[workflows.steps]]
type = "Release"

# Needed because Knope doesn't have built-in GitLab support
[[workflows.steps]]
type = "Command"
command = "git push --push-option ci.skip"

[[workflows.steps]]
type = "Command"
command = "git push --tags --push-option ci.skip"

[[workflows.steps]]
type = "Command"
# See https://docs.gitlab.com/ee/user/project/releases/release_cli.html
command = "release-cli create --name \"Release $version\" --tag-name \"v$version\" --ref \"v$version\""

[workflows.steps.variables]
"$version" = "Version"

And the working one:

[package]
versioned_files = ["python-grpc/pyproject.toml", "python-grpc-betterproto/pyproject.toml", "rust/Cargo.toml", "golang/go.mod"]

[[workflows]]
name = "release"

[[workflows.steps]]
type = "PrepareRelease"
allow_empty = true

[[workflows.steps]]
type = "Command"
# Knope feature request to make this behavior automatic:
# https://github.com/knope-dev/knope/issues/162
command = "cargo update -w --manifest-path rust/Cargo.toml"

# Needed so that `prepare` and `release` can run in separate CI steps
[[workflows.steps]]
type = "Command"
command = "git add python-grpc/pyproject.toml python-grpc-betterproto/pyproject.toml rust/Cargo.toml rust/Cargo.lock golang/go.mod"

[[workflows.steps]]
type = "Command"
command = "git commit -m \"chore: prepare release $version\""

[workflows.steps.variables]
# `Version` is a "magic" Knope string that will be replaced with the actual version
"$version" = "Version"

[[workflows.steps]]
type = "Release"

# Needed because Knope doesn't have built-in GitLab support
[[workflows.steps]]
type = "Command"
command = "git push --push-option ci.skip"

[[workflows.steps]]
type = "Command"
command = "git push --tags --push-option ci.skip"

[[workflows.steps]]
type = "Command"
# See https://docs.gitlab.com/ee/user/project/releases/release_cli.html
command = "release-cli create --name \"Release $version\" --tag-name \"v$version\" --ref \"v$version\""

[workflows.steps.variables]
"$version" = "Version"

The diff is merely:

--- a/knope.toml
+++ b/knope.toml
@@ -2,7 +2,7 @@
 versioned_files = ["python-grpc/pyproject.toml", "python-grpc-betterproto/pyproject.toml", "rust/Cargo.toml", "golang/go.mod"]

 [[workflows]]
-name = "prepare"
+name = "release"

 [[workflows.steps]]
 type = "PrepareRelease"
@@ -14,9 +14,6 @@
 # https://github.com/knope-dev/knope/issues/162
 command = "cargo update -w --manifest-path rust/Cargo.toml"

-[[workflows]]
-name = "release"
-
 # Needed so that `prepare` and `release` can run in separate CI steps
 [[workflows.steps]]
 type = "Command"

Additionally, this is with v0.16.0; but I tested with v0.18.1 locally, without any push logic, and the behavior appeared to be the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants