-
Notifications
You must be signed in to change notification settings - Fork 357
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
Allow on demand dev releases #450
Conversation
@@ -84,6 +84,7 @@ jobs: | |||
- name: Bump version.py | |||
run: | | |||
export module=$(sed 's/^.*\///' <<< ${{ matrix.package.name }} | tr '-' '/') | |||
export version=$(sed -E 's|-(\d*)|${{ github.ref == 'refs/heads/main' && '' || '-dev' }}\1|g' <<< ${{ matrix.package.version }}) |
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.
pnpm ci:version --snapshot dev
already produces x.y.z-dev-TIMESTAMP
, there's no need to add another -dev
to it, just trim down the last dash.
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.
ah, thanks! will do
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.
pushed the change, it looks a bit ugly as I read that nested expressions aren't supported. If you were thinking of a more elegant solution feel free to commit it to this branch!
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.
i think this one is clearer: 's|-\([0-9]*\)$|\1|'
(take dash-numbers-eol and turn it into numbers-eol). doesn't even need an if clause, really.
also note that sed regexes require \(
\)
for grouping, with literal backslashes, and don't support \d
as a capture group. https://sed.js.org has worked for me for quick testing
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.
yeah, that seems cleaner!
the -E
argument allows for brackets not to be escaped, but can go with the regular version of escaping it.
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.
Can pypi recognize v0.1.0-dev
too? I've only used v0.1.0.dev0
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.
https://peps.python.org/pep-0440/
Epoch segment: N!
Release segment: N(.N)*
Pre-release segment: {a|b|rc}N
Post-release segment: .postN
Development release segment: .devN
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.
Ah ignore my comments. it seems like it should work: https://peps.python.org/pep-0440/#development-release-separators
Development releases allow a ., -, or a _ separator as well as omitting the separator all together. The normal form of this is with the . separator. This allows versions such as 1.2-dev2 or 1.2dev2 which normalize to 1.2.dev2.
From @nbsp comment, not sure if the timestamp will be recognized (x.y.z-dev-TIMESTAMP)
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.
the timestamp is only numbers, so even though it doesn't follow the "spirit" of the spec, i think it technically abides by it. version numbers aren't consecutive but they are ordered
0.0.0-dev-1234567890 -> 0.0.0-dev1234567890 -> 0.0.0.dev1234567890
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.
Just did some testing with the official regex:
>>> import re
>>> VERSION_PATTERN = r"""
... v?
... (?:
... (?:(?P<epoch>[0-9]+)!)? # epoch
... (?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
... (?P<pre> # pre-release
... [-_\.]?
... (?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
... [-_\.]?
... (?P<pre_n>[0-9]+)?
... )?
... (?P<post> # post release
... (?:-(?P<post_n1>[0-9]+))
... |
... (?:
... [-_\.]?
... (?P<post_l>post|rev|r)
... [-_\.]?
... (?P<post_n2>[0-9]+)?
... )
... )?
... (?P<dev> # dev release
... [-_\.]?
... (?P<dev_l>dev)
... [-_\.]?
... (?P<dev_n>[0-9]+)?
... )?
... )
... (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
... """
>>>
>>> _regex = re.compile(
... r"^\s*" + VERSION_PATTERN + r"\s*$",
... re.VERBOSE | re.IGNORECASE,
... )
>>>
>>>
>>> _regex.match("v0.1.0.dev0")
<re.Match object; span=(0, 11), match='v0.1.0.dev0'>
>>> _regex.match("v0.1.0.dev-0")
<re.Match object; span=(0, 12), match='v0.1.0.dev-0'>
>>> _regex.match("v0.1.0.dev-1")
<re.Match object; span=(0, 12), match='v0.1.0.dev-1'>
>>> _regex.match("v0.1.0.dev-143535365346")
<re.Match object; span=(0, 23), match='v0.1.0.dev-143535365346'>
>>> _regex.match("v0.1.0-dev-143535365346")
<re.Match object; span=(0, 23), match='v0.1.0-dev-143535365346'>
>>> _regex.match("v0.1.0-dev-153562")
<re.Match object; span=(0, 17), match='v0.1.0-dev-153562'>
Seems like the current format is OK, lgtm! Thanks!
Note that this one is not valid tho: |
should I merge this into |
merging to main lgtm |
No description provided.