Implement beta publishing on development branch#85
Implement beta publishing on development branch#85VikramGoyal23 wants to merge 11 commits intogit-mastery:mainfrom
Conversation
1707c2d to
a7c9451
Compare
a7c9451 to
275576b
Compare
8c7e033 to
bb5aba5
Compare
|
@VikramGoyal23 Can we check on status of this? Hopefully we can get this merged soon before the semester ends. |
70ffcf3 to
03d3902
Compare
While the version parsing could be trivially solved using regex matching, I opted to build on the current logic for now. Should maybe come back to it in the future.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ("beta" in version and len(parts) != 4) or ("beta" not in version and len(parts) != 3): | ||
| raise ValueError( | ||
| f"Invalid version string (expected 'MAJOR.MINOR.PATCH'): {version!r}" | ||
| f"Invalid version string (expected 'MAJOR.MINOR.PATCH[-beta.PRERELEASE]'): {version!r}" | ||
| ) | ||
| try: | ||
| major, minor, patch = (int(part) for part in parts) | ||
| if "beta" in version: | ||
| version_part, prerelease_str = version.split("-beta.") | ||
| prerelease = int(prerelease_str) | ||
| major, minor, patch = (int(part) for part in version_part.split(".")) |
There was a problem hiding this comment.
parse uses "beta" in version to decide beta parsing/validation. This can incorrectly route versions that merely contain the substring "beta" and it doesn't assert the presence of the -beta. separator before calling version.split("-beta."). Use a stricter check like "-beta." in version (and validate the split yields exactly 2 parts) to avoid false positives and confusing exceptions.
| """Returns if the current version is behind the other version based on major and minor versions.""" | ||
| if self.prerelease is not None and other.prerelease is not None: | ||
| return (other.major, other.minor, other.patch, other.prerelease) > ( | ||
| self.major, | ||
| self.minor, | ||
| self.patch, | ||
| self.prerelease, | ||
| ) | ||
| return (other.major, other.minor) > (self.major, self.minor) | ||
|
|
There was a problem hiding this comment.
is_behind now compares (major, minor, patch, prerelease) only when both versions are prereleases, but falls back to comparing only (major, minor) for stable versions and for mixed stable/prerelease comparisons. This breaks SemVer ordering in common cases (e.g., 1.2.3-beta.1 should be behind 1.2.3, and 1.2.3 should be behind 1.2.4), and the docstring no longer matches behavior. Consider comparing (major, minor, patch) first in all cases, then applying prerelease ordering when base versions are equal (stable > prerelease; if both prerelease, compare prerelease number).
| """Returns if the current version is behind the other version based on major and minor versions.""" | |
| if self.prerelease is not None and other.prerelease is not None: | |
| return (other.major, other.minor, other.patch, other.prerelease) > ( | |
| self.major, | |
| self.minor, | |
| self.patch, | |
| self.prerelease, | |
| ) | |
| return (other.major, other.minor) > (self.major, self.minor) | |
| """Return whether the current version is behind the other version using SemVer ordering.""" | |
| self_base = (self.major, self.minor, self.patch) | |
| other_base = (other.major, other.minor, other.patch) | |
| if self_base != other_base: | |
| return self_base < other_base | |
| if self.prerelease is None and other.prerelease is None: | |
| return False | |
| if self.prerelease is None: | |
| return False | |
| if other.prerelease is None: | |
| return True | |
| return self.prerelease < other.prerelease |
| winget-publish: | ||
| needs: [prepare, windows] | ||
| if: needs.prepare.outputs.should_publish == 'true' && !contains(needs.prepare.outputs.ref_name, 'beta') # temporarily disable winget publishing | ||
|
|
||
| runs-on: windows-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Submit to WinGet | ||
| uses: vedantmgoyal9/winget-releaser@v2 | ||
| with: | ||
| identifier: GitMastery.GitMasteryBeta | ||
| version: ${{ needs.prepare.outputs.version_number }} | ||
| release-tag: ${{ needs.prepare.outputs.ref_name }} | ||
| token: ${{ secrets.ORG_PAT }} | ||
| installers-regex: '\.exe$' |
There was a problem hiding this comment.
The winget-publish job is effectively unreachable in this workflow: the workflow triggers on v*.*.*-beta.* tags and is named/purposed for beta publishing, but the job additionally requires !contains(..., 'beta'), so it will never run for the intended beta tags. If WinGet publishing is intentionally disabled, consider removing the job or gating it behind an explicit workflow input so the condition is not contradictory/misleading.
| on: | ||
| workflow_dispatch: | ||
| secrets: | ||
| ORG_PAT: | ||
| required: true | ||
|
|
There was a problem hiding this comment.
workflow_dispatch does not support a secrets: schema (only inputs:). As written, this won't actually enforce that ORG_PAT is provided, and the workflow may run and fail later with a confusing auth error. Consider removing this block and instead adding an early step that validates ${{ secrets.ORG_PAT }} is set (or use a protected environment with required reviewers/required secrets).
| only_version = version[1:] | ||
| if "beta" in only_version: | ||
| version_part, prerelease = only_version.split("-beta.") | ||
| [major, minor, patch] = version_part.split(".") | ||
| return Version(int(major), int(minor), int(patch), int(prerelease)) |
There was a problem hiding this comment.
parse_version_string checks "beta" in only_version and then blindly splits on -beta.. This will mis-detect unrelated substrings (e.g., "alphabet") and will raise an unhelpful ValueError if the string contains "beta" but not the expected -beta. delimiter. Prefer checking for the exact -beta. marker and raising a clear ValueError (or falling back to stable parsing) when the beta format is malformed.
|
@VikramGoyal23 feel free to merge and test once ur ready, let us know when it is ready so we can approve it |
|
@jovnc It's ready, can be approved |
|
@VikramGoyal23 I have disabled require approval as of now, so feel free to merge the PRs and debug as necessary |
Should be merged after the actions PR and after
gitmastery-betais registered on AUR and Winget.RFC: https://docs.google.com/document/d/17ZhVua_eH_mWQIDc90ojq6EkiolRXQa5asBBvZhgfAU/edit?tab=t.0