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

ci: release without committing to main branch #1434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

calumcalder
Copy link
Collaborator

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.

@calumcalder calumcalder requested review from jzacsh and lisad February 14, 2025 15:14
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.
Copy link
Collaborator

@jzacsh jzacsh left a 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}"
Copy link
Collaborator

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:

Suggested change
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)
Copy link
Collaborator

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):

Suggested change
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"
Copy link
Collaborator

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:

Suggested change
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
Copy link
Collaborator

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)

Suggested change
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

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

Successfully merging this pull request may close these issues.

2 participants