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

Allow on demand dev releases #450

Merged
merged 5 commits into from
Jul 21, 2024
Merged

Allow on demand dev releases #450

merged 5 commits into from
Jul 21, 2024

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Jul 18, 2024

No description provided.

@@ -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 }})
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, thanks! will do

Copy link
Contributor Author

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!

Copy link
Member

@nbsp nbsp Jul 18, 2024

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

Copy link
Contributor Author

@lukasIO lukasIO Jul 19, 2024

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.

Copy link
Member

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

Copy link
Member

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

Copy link
Member

@theomonnom theomonnom Jul 19, 2024

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)

Copy link
Member

@nbsp nbsp Jul 19, 2024

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

@lukasIO lukasIO marked this pull request as ready for review July 19, 2024 07:37
@lukasIO lukasIO requested review from nbsp and theomonnom July 19, 2024 10:27
@lukasIO lukasIO changed the title allow on demand dev releases Allow on demand dev releases Jul 19, 2024
Copy link
Member

@theomonnom theomonnom left a 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!

@theomonnom
Copy link
Member

Note that this one is not valid tho:
_regex.match("v0.1.0-dev1-1234532")

@lukasIO
Copy link
Contributor Author

lukasIO commented Jul 21, 2024

should I merge this into main or into dev ? 👀
In the end we'll need it in both anyways as the action won't show up in the actions tab if it's not present in the default branch of the repo, just wondering about the ordering mostly.

@theomonnom
Copy link
Member

merging to main lgtm

@lukasIO lukasIO merged commit 48587af into main Jul 21, 2024
2 of 4 checks passed
@lukasIO lukasIO deleted the lukas/dev-releases branch July 21, 2024 17:06
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.

3 participants