-
Notifications
You must be signed in to change notification settings - Fork 481
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
ci: release without committing to main branch #1434
base: master
Are you sure you want to change the base?
Conversation
Committing to the master branch isn't allowed from github actions because of our branch protection rules. There's no easy way to allow github actions to bypass this. As a workaround, skip all the parts of the release that needed to commit to the repo. This means moving the version config to an environment variable, which shouldn't be an issue.
af75b87
to
cd229d2
Compare
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.
thanks for figuring this all out! Feel free to ack/ignore all these since they're all optional!
run: | | ||
VERSION=$(cz bump --get-next) | ||
TAG="v${VERSION}" | ||
git tag "${TAG}" |
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.
(same thread really) totally optional, just playing it extra safe:
git tag "${TAG}" | |
git tag "${TAG}" && | |
git push origin "${TAG}" --tags && | |
echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" |
- id: tag | ||
name: "Tag release" | ||
run: | | ||
VERSION=$(cz bump --get-next) |
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.
totally optional, just playing it extra safe with a new || exit 1
(and clarifying NEW_
as this, cz...bump
CLI, is real origin of our version now):
VERSION=$(cz bump --get-next) | |
NEW_VERSION=$(cz bump --get-next) || exit 1 |
- name: "Install commitizen" | ||
run: pip install --user -U commitizen | ||
- id: tag | ||
name: "Tag release" |
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.
optional, to clarify we're mutating the repo's git state:
name: "Tag release" | |
name: "Release: Publish new semver Git Tag" |
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: "Install commitizen" | ||
run: pip install --user -U commitizen |
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.
optional: wearing my supply-chain-debugging hat
could we add a line of --version output or something, so we have historical data on what version of commitizen
is working for us (in case we're debugging a break int he future)
run: pip install --user -U commitizen | |
run: | | |
pip install --user -U commitizen && | |
cz version --verbose |
(looks like it self-reports its name, so don't need to add our own echo or anything to explain in our own logs)
@@ -14,7 +14,7 @@ The action contains two jobs; one to bump the version number of the DTP packages | |||
|
|||
DTP uses [Semantic Versioning](https://semver.org/) for published packages. We also enforce [Conventional Commits](https://conventionalcommits.org/) on the `master` branch through the `.github/workflows/commitlint.yml` Github action, which lets us automatically calculate version numbers. | |||
|
|||
Commitizen is a tool that supports automatically incrementing SemVer version numbers based on git commit history. Our usage of Commitizen is configured in `.cz.toml`, and uses the `commitizen-tools/commitizen-action` Github action to automatically bump the package version number and to tag the new version in git. | |||
Commitizen is a tool that supports automatically incrementing SemVer version numbers based on git commit history. Our usage of Commitizen is configured in `.cz.toml`, and is used in a Github action to automatically tag the new version in git. |
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.
Commitizen is a tool that supports automatically incrementing SemVer version numbers based on git commit history. Our usage of Commitizen is configured in `.cz.toml`, and is used in a Github action to automatically tag the new version in git. | |
Commitizen is a tool that supports automatically incrementing SemVer version numbers based on git commit history. Our usage of Commitizen is configured in `.cz.toml`, and is used in a Github action to automatically tag the new version in git and publish to maven (per "automated publishing" section of this doc). |
Committing to the master branch isn't allowed from github actions because of our branch protection rules. There's no easy way to allow github actions to bypass this.
As a workaround, skip all the parts of the release that needed to commit to the repo. This means moving the version config to an environment variable, which shouldn't be an issue, and using git tags as the source of truth.