Skip to content

ci: calculate build number based on the commit history#1383

Merged
staceybeard merged 25 commits intomainfrom
SB.ci-cd-build-number
May 26, 2025
Merged

ci: calculate build number based on the commit history#1383
staceybeard merged 25 commits intomainfrom
SB.ci-cd-build-number

Conversation

@staceybeard
Copy link
Member

By submitting this merge request, I confirm the following:

  • The merge request title follows the conventional commits convention (see Backend project's README.md)
    • feat: minor app version will be incremented.
    • fix, deps, perf: patch app version will be incremented.
    • chore, ci, etc.: app version will not be incremented.
    • See semantic-release/commit-analyzer
      for complete set of rules.

Changes

Added steps to the build-setup action to calculate a build number based on the number of commits between tags. For example, the first commit tagged v2.0.0 will be 2.0.0 (1). The next commit will be 2.0.0 (2), and so on, until the next tag.

Dependencies

  • Listener: N/A

@staceybeard staceybeard self-assigned this May 22, 2025
@staceybeard staceybeard requested a review from mschoettle May 22, 2025 21:30
with:
persist-credentials: false
# Fetch part of the commit history and its tags, in order to calculate the build number in `build-setup`
fetch-depth: 100
Copy link
Member

Choose a reason for hiding this comment

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

This value is repeated a few times. Is there a way to define it once?

In addition, is 100 safe? If I understand this right, if there are more than 100 commits since the last release this won't work anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem, I've added it as a variable.

For the value, you're right, it wouldn't work in that case. It's a bit of a best guess (enough commits to work, not so many that it's overkill). I think we're unlikely to reach 100 commits between versions with the current team size. But I can easily change it if needed.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I think it's fine for now as it is. With regular releases this should hopefully never occur.

@mschoettle
Copy link
Member

Nice work. Added a few questions, nothing that we absolutely need to change (given that it is probably time-intensive to test this).

staceybeard and others added 3 commits May 26, 2025 10:42
@staceybeard
Copy link
Member Author

Nice work. Added a few questions, nothing that we absolutely need to change (given that it is probably time-intensive to test this).

Thanks, Matthias!

@staceybeard staceybeard requested a review from mschoettle May 26, 2025 15:39
with:
persist-credentials: false
# Fetch part of the commit history and its tags, in order to calculate the build number in `build-setup`
fetch-depth: 100
Copy link
Member

Choose a reason for hiding this comment

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

Thanks. I think it's fine for now as it is. With regular releases this should hopefully never occur.

@mschoettle
Copy link
Member

mschoettle commented May 26, 2025

Wait, one question remains: Does this mean we can avoid semantic release committing to main every time we merge a PR?

@staceybeard
Copy link
Member Author

Wait, one question remains: Does this mean we can avoid semantic release committing to main every time we merge a PR?

Yes, that's right. I'm going to add semantic release as a manual workflow, so we'll only need to run it and have it commit when we want to bump the version number, so not for every commit.

@staceybeard staceybeard merged commit e0a99d1 into main May 26, 2025
4 checks passed
@staceybeard staceybeard deleted the SB.ci-cd-build-number branch May 26, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants