Do not create an initial release when the project is generated#365
Merged
Do not create an initial release when the project is generated#365
Conversation
added 3 commits
June 8, 2020 08:06
Releases are triggered by version bumps, so projects should not be generated with version 0.1.0, the initial version recommended by the Semantic Versioning standard. Starting at 0.0.0 allows any non-zero version to be used as the initial version.
The Release workflow detects a bogus previous version if the parent commit does not contain a pyproject.toml file with a `tool.poetry.version` field. Poetry is run as the first job in a pipeline, so its non-zero exit code is not reported back to the action. Poetry writes its error message to stdout, which results in a reported version "could" (second word of the error message). Fix this by running the command via `bash -o pipefail -c`. Note that it is not possible to use `set -o pipefail` inside the version command. The GitHub Action (salsify/action-detect-and-tag-new-version) always uses /bin/sh, which happens to be dash in Ubuntu. The dash shell does not support pipefail.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR contains the following changes:
0.0.0by defaultCloses #334
Note that even with this PR, the Release workflow will fail if there is a parent commit which does not contain a Poetry-managed project. IMO this is best fixed upstream, by displaying a warning if the previous version number cannot be detected, instead of failing the workflow.
Discussion
These changes address several problems with the Release workflow when the generated project is initially pushed to GitHub. There are several different scenarios where this comes into play:
Scenario 1
Before the PR: The workflow would fail because of a missing parent commit. As the version number is already
0.1.0, and releases require a version bump, it would be impossible to release this version.After the PR: The workflow will skip the tagging (producing only a TestPyPI release and draft GitHub release). Subsequent commits can create the initial release by bumping the version from
0.0.0to0.1.0.Scenarios 2, 3, and 5
Before the PR: The initial import would result in an unintended release of
0.1.0, due to a detected version bump fromcould(from Poetry's error message) to0.1.0.After the PR: The workflow will fail because the parent commit does not define a version in
pyproject.toml. Subsequent commits can create an initial release by bumping the version from0.0.0to0.1.0.Scenario 4
It depends if the existing project has seen a release. If so, and that version number was used when generating the project structure, there is no breakage before and after this PR. The workflow will succeed without creating a release.
Otherwise (i.e. if the project was unreleased):
Before this PR: If the default version number of
0.1.0was used both in the existing project and in the generated project, the workflow would succeed without creating a release, but subsequent commits would be unable to release0.1.0.After this PR: The recommended method is to first reset the version to
0.0.0before importing the project structure. This will avoid a bogus0.0.0release when importing the Release workflow.Additional notes from the commit messages
Releases are triggered by version bumps, so projects should not be
generated with version 0.1.0, the initial version recommended by the
Semantic Versioning standard. Starting at 0.0.0 allows any non-zero
version to be used as the initial version.
poetry versionexits with failureThe Release workflow detects a bogus previous version if the parent commit does
not contain a pyproject.toml file with a
tool.poetry.versionfield.Poetry is run as the first job in a pipeline, so its non-zero exit code is not
reported back to the action. Poetry writes its error message to stdout, which
results in a reported version "could" (second word of the error message).
Fix this by running the command via
bash -o pipefail -c. Note that it is notpossible to use
set -o pipefailinside the version command. The GitHubAction (salsify/action-detect-and-tag-new-version) always uses /bin/sh, which
happens to be dash in Ubuntu. The dash shell does not support pipefail.