lupaxa-language-versions 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lupaxa_language_versions-0.1.0/.gitignore +23 -0
- lupaxa_language_versions-0.1.0/LICENCE +21 -0
- lupaxa_language_versions-0.1.0/PKG-INFO +169 -0
- lupaxa_language_versions-0.1.0/README.md +110 -0
- lupaxa_language_versions-0.1.0/docs/README.md +23 -0
- lupaxa_language_versions-0.1.0/pyproject.toml +119 -0
- lupaxa_language_versions-0.1.0/src/lupaxa/language_versions/__init__.py +7 -0
- lupaxa_language_versions-0.1.0/src/lupaxa/language_versions/cli.py +146 -0
- lupaxa_language_versions-0.1.0/src/lupaxa/language_versions/lookup.py +238 -0
- lupaxa_language_versions-0.1.0/src/lupaxa/language_versions/version.py +10 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
# Cursor
|
|
5
|
+
.superpowers/
|
|
6
|
+
cursor-docs
|
|
7
|
+
|
|
8
|
+
# Make
|
|
9
|
+
.makefiles/
|
|
10
|
+
|
|
11
|
+
# MkDocs
|
|
12
|
+
site/
|
|
13
|
+
|
|
14
|
+
# Python
|
|
15
|
+
.venv/
|
|
16
|
+
__pycache__/
|
|
17
|
+
.mypy_cache/
|
|
18
|
+
.ruff_cache/
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.coverage
|
|
21
|
+
dist/
|
|
22
|
+
build/
|
|
23
|
+
*.egg-info/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) The Lupaxa Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: lupaxa-language-versions
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local CLI companion to the Get Language Versions GitHub Action.
|
|
5
|
+
Project-URL: Homepage, https://github.com/lupaxa-actions-toolbox/language-versions
|
|
6
|
+
Project-URL: Repository, https://github.com/lupaxa-actions-toolbox/language-versions
|
|
7
|
+
Project-URL: Issues, https://github.com/lupaxa-actions-toolbox/language-versions/issues
|
|
8
|
+
Project-URL: Get Language Versions Action, https://github.com/lupaxa-actions-toolbox/get-language-versions
|
|
9
|
+
Author: The Lupaxa Project
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) The Lupaxa Project
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENCE
|
|
32
|
+
Keywords: cli,github-actions,go,node,python,versions
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
43
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
44
|
+
Requires-Python: >=3.11
|
|
45
|
+
Requires-Dist: packaging>=24.2
|
|
46
|
+
Requires-Dist: requests>=2.32.5
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: bump-my-version>=1.2.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: hatch>=1.12.0; extra == 'dev'
|
|
50
|
+
Requires-Dist: mypy>=1.12.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: pip-audit>=2.7.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: ruff>=0.6.0; extra == 'dev'
|
|
55
|
+
Provides-Extra: test
|
|
56
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'test'
|
|
57
|
+
Requires-Dist: pytest>=8.0; extra == 'test'
|
|
58
|
+
Description-Content-Type: text/markdown
|
|
59
|
+
|
|
60
|
+
<p align="center">
|
|
61
|
+
<a href="https://github.com/lupaxa-actions-toolbox">
|
|
62
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/actions-toolbox/readme-logo.png" alt="Actions Toolbox" />
|
|
63
|
+
</a>
|
|
64
|
+
</p>
|
|
65
|
+
|
|
66
|
+
<h1 align="center">Language Versions</h1>
|
|
67
|
+
|
|
68
|
+
Local supporting tool for the [Get Language Versions](https://github.com/lupaxa-actions-toolbox/get-language-versions) GitHub Action.
|
|
69
|
+
It lives in Actions Toolbox so it sits next to that action.
|
|
70
|
+
Install it on your machine, look up the same runtime versions the action would return, and copy the ones you want into the workflow.
|
|
71
|
+
|
|
72
|
+
The action remains the workflow step. This command prints a table of the flags you passed and the versions that matched. It does not replace `lupaxa-actions-toolbox/get-language-versions`.
|
|
73
|
+
|
|
74
|
+
> **Note:** The action still writes JSON to `latest-versions` for `fromJson`. This command prints the same versions in a table.
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install lupaxa-language-versions
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The first stable GitHub release publishes the package to PyPI.
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
language-versions python
|
|
88
|
+
language-versions python --min-version 3.11 --max-version 3.13
|
|
89
|
+
language-versions python --highest-only
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The table lists the flags used, then the matching versions. `--highest-only` keeps a single version in that list.
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
┌──────────────────────┬─────────────────┐
|
|
96
|
+
│ Flag │ Value │
|
|
97
|
+
├──────────────────────┼─────────────────┤
|
|
98
|
+
│ language │ python │
|
|
99
|
+
│ min-version │ 3.11 │
|
|
100
|
+
│ max-version │ latest │
|
|
101
|
+
│ max-versions │ 0 (every match) │
|
|
102
|
+
│ include-prereleases │ no │
|
|
103
|
+
│ highest-only │ no │
|
|
104
|
+
│ remove-patch-version │ no │
|
|
105
|
+
│ use-head │ no │
|
|
106
|
+
├──────────────────────┴─────────────────┤
|
|
107
|
+
│ Versions (3) │
|
|
108
|
+
├────────────────────────────────────────┤
|
|
109
|
+
│ 3.11.9 │
|
|
110
|
+
│ 3.12.1 │
|
|
111
|
+
│ 3.13.0 │
|
|
112
|
+
└────────────────────────────────────────┘
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The versions in that table are an example of the layout.
|
|
116
|
+
|
|
117
|
+
## Invalid Input
|
|
118
|
+
|
|
119
|
+
An invalid argument prints one error line, then the help text. The error line is red in a terminal.
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
[ Error ] argument language: invalid choice: 'fish' (choose from go, node, nodejs, perl, php, python, ruby)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Check the versions locally, then keep the action in the workflow:
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
- uses: lupaxa-actions-toolbox/get-language-versions@master
|
|
129
|
+
id: get-versions
|
|
130
|
+
with:
|
|
131
|
+
language: "python"
|
|
132
|
+
min-version: "3.11"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
language-versions python --min-version 3.11
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Options
|
|
140
|
+
|
|
141
|
+
The flags match the action inputs.
|
|
142
|
+
|
|
143
|
+
| Option | Default | Meaning |
|
|
144
|
+
| :--------------------- | :------ | :----------------------------------------------------------------------- |
|
|
145
|
+
| language | | go, node, nodejs, perl, php, python, or ruby. Required. |
|
|
146
|
+
| --min-version | eol | Lowest major.minor. eol is the oldest supported release. all is every. |
|
|
147
|
+
| --max-version | latest | Highest major.minor, or latest for no upper bound. |
|
|
148
|
+
| --max-versions | 0 | 0 keeps every match. A positive number keeps that many newest versions. |
|
|
149
|
+
| --include-prereleases | off | Include prerelease versions. |
|
|
150
|
+
| --highest-only | off | Keep only the highest matching version. |
|
|
151
|
+
| --remove-patch-version | off | Print major.minor only. Cannot be combined with --include-prereleases. |
|
|
152
|
+
| --use-head | off | Read the default branch instead of the latest release. Ignored for PHP. |
|
|
153
|
+
|
|
154
|
+
## Version Sources
|
|
155
|
+
|
|
156
|
+
The command reads the same lists as the action.
|
|
157
|
+
|
|
158
|
+
| Language | Setup Action | Version Source |
|
|
159
|
+
| :------- | :------------------------------------------------------------- | :--------------------------------------------------------------------- |
|
|
160
|
+
| Go | [setup-go](https://github.com/actions/setup-go) | [go-versions](https://github.com/actions/go-versions) |
|
|
161
|
+
| Node | [setup-node](https://github.com/actions/setup-node) | [node-versions](https://github.com/actions/node-versions) |
|
|
162
|
+
| Perl | [setup-perl](https://github.com/shogo82148/actions-setup-perl) | [actions-setup-perl](https://github.com/shogo82148/actions-setup-perl) |
|
|
163
|
+
| PHP | [setup-php](https://github.com/shivammathur/setup-php) | [phpreleases](https://phpreleases.com/api/releases/) |
|
|
164
|
+
| Python | [setup-python](https://github.com/actions/setup-python) | [python-versions](https://github.com/actions/python-versions) |
|
|
165
|
+
| Ruby | [setup-ruby](https://github.com/ruby/setup-ruby) | [setup-ruby](https://github.com/ruby/setup-ruby) |
|
|
166
|
+
|
|
167
|
+
<a href="https://github.com/the-lupaxa-project">
|
|
168
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
|
|
169
|
+
</a>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/lupaxa-actions-toolbox">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/actions-toolbox/readme-logo.png" alt="Actions Toolbox" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Language Versions</h1>
|
|
8
|
+
|
|
9
|
+
Local supporting tool for the [Get Language Versions](https://github.com/lupaxa-actions-toolbox/get-language-versions) GitHub Action.
|
|
10
|
+
It lives in Actions Toolbox so it sits next to that action.
|
|
11
|
+
Install it on your machine, look up the same runtime versions the action would return, and copy the ones you want into the workflow.
|
|
12
|
+
|
|
13
|
+
The action remains the workflow step. This command prints a table of the flags you passed and the versions that matched. It does not replace `lupaxa-actions-toolbox/get-language-versions`.
|
|
14
|
+
|
|
15
|
+
> **Note:** The action still writes JSON to `latest-versions` for `fromJson`. This command prints the same versions in a table.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install lupaxa-language-versions
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The first stable GitHub release publishes the package to PyPI.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
language-versions python
|
|
29
|
+
language-versions python --min-version 3.11 --max-version 3.13
|
|
30
|
+
language-versions python --highest-only
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The table lists the flags used, then the matching versions. `--highest-only` keeps a single version in that list.
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
┌──────────────────────┬─────────────────┐
|
|
37
|
+
│ Flag │ Value │
|
|
38
|
+
├──────────────────────┼─────────────────┤
|
|
39
|
+
│ language │ python │
|
|
40
|
+
│ min-version │ 3.11 │
|
|
41
|
+
│ max-version │ latest │
|
|
42
|
+
│ max-versions │ 0 (every match) │
|
|
43
|
+
│ include-prereleases │ no │
|
|
44
|
+
│ highest-only │ no │
|
|
45
|
+
│ remove-patch-version │ no │
|
|
46
|
+
│ use-head │ no │
|
|
47
|
+
├──────────────────────┴─────────────────┤
|
|
48
|
+
│ Versions (3) │
|
|
49
|
+
├────────────────────────────────────────┤
|
|
50
|
+
│ 3.11.9 │
|
|
51
|
+
│ 3.12.1 │
|
|
52
|
+
│ 3.13.0 │
|
|
53
|
+
└────────────────────────────────────────┘
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The versions in that table are an example of the layout.
|
|
57
|
+
|
|
58
|
+
## Invalid Input
|
|
59
|
+
|
|
60
|
+
An invalid argument prints one error line, then the help text. The error line is red in a terminal.
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
[ Error ] argument language: invalid choice: 'fish' (choose from go, node, nodejs, perl, php, python, ruby)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Check the versions locally, then keep the action in the workflow:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- uses: lupaxa-actions-toolbox/get-language-versions@master
|
|
70
|
+
id: get-versions
|
|
71
|
+
with:
|
|
72
|
+
language: "python"
|
|
73
|
+
min-version: "3.11"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
language-versions python --min-version 3.11
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Options
|
|
81
|
+
|
|
82
|
+
The flags match the action inputs.
|
|
83
|
+
|
|
84
|
+
| Option | Default | Meaning |
|
|
85
|
+
| :--------------------- | :------ | :----------------------------------------------------------------------- |
|
|
86
|
+
| language | | go, node, nodejs, perl, php, python, or ruby. Required. |
|
|
87
|
+
| --min-version | eol | Lowest major.minor. eol is the oldest supported release. all is every. |
|
|
88
|
+
| --max-version | latest | Highest major.minor, or latest for no upper bound. |
|
|
89
|
+
| --max-versions | 0 | 0 keeps every match. A positive number keeps that many newest versions. |
|
|
90
|
+
| --include-prereleases | off | Include prerelease versions. |
|
|
91
|
+
| --highest-only | off | Keep only the highest matching version. |
|
|
92
|
+
| --remove-patch-version | off | Print major.minor only. Cannot be combined with --include-prereleases. |
|
|
93
|
+
| --use-head | off | Read the default branch instead of the latest release. Ignored for PHP. |
|
|
94
|
+
|
|
95
|
+
## Version Sources
|
|
96
|
+
|
|
97
|
+
The command reads the same lists as the action.
|
|
98
|
+
|
|
99
|
+
| Language | Setup Action | Version Source |
|
|
100
|
+
| :------- | :------------------------------------------------------------- | :--------------------------------------------------------------------- |
|
|
101
|
+
| Go | [setup-go](https://github.com/actions/setup-go) | [go-versions](https://github.com/actions/go-versions) |
|
|
102
|
+
| Node | [setup-node](https://github.com/actions/setup-node) | [node-versions](https://github.com/actions/node-versions) |
|
|
103
|
+
| Perl | [setup-perl](https://github.com/shogo82148/actions-setup-perl) | [actions-setup-perl](https://github.com/shogo82148/actions-setup-perl) |
|
|
104
|
+
| PHP | [setup-php](https://github.com/shivammathur/setup-php) | [phpreleases](https://phpreleases.com/api/releases/) |
|
|
105
|
+
| Python | [setup-python](https://github.com/actions/setup-python) | [python-versions](https://github.com/actions/python-versions) |
|
|
106
|
+
| Ruby | [setup-ruby](https://github.com/ruby/setup-ruby) | [setup-ruby](https://github.com/ruby/setup-ruby) |
|
|
107
|
+
|
|
108
|
+
<a href="https://github.com/the-lupaxa-project">
|
|
109
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
|
|
110
|
+
</a>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/lupaxa-actions-toolbox">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/actions-toolbox/readme-logo.png" alt="Organisation Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">Core Documentation</h1>
|
|
8
|
+
|
|
9
|
+
The following documents define the standards that apply across **The Lupaxa Project**:
|
|
10
|
+
|
|
11
|
+
| Document | Purpose |
|
|
12
|
+
| :------------------------------------ | :---------------------------------------------------------------- |
|
|
13
|
+
| [Code of Conduct](CODE_OF_CONDUCT.md) | Expected behaviour and reporting procedures. |
|
|
14
|
+
| [How to Contribute](CONTRIBUTING.md) | Development workflow, coding standards, and contribution process. |
|
|
15
|
+
| [Governance](GOVERNANCE.md) | Project governance, roles, and decision-making. |
|
|
16
|
+
| [Maintainers](MAINTAINERS.md) | Maintainer responsibilities and expectations. |
|
|
17
|
+
| [Projects Overview](PROJECTS.md) | Overview of organisations, repositories, and project structure. |
|
|
18
|
+
| [Security Policy](SECURITY.md) | Responsible disclosure and secure development practices. |
|
|
19
|
+
| [Support Guide](SUPPORT.md) | How to obtain help and support. |
|
|
20
|
+
|
|
21
|
+
<a href="https://github.com/the-lupaxa-project">
|
|
22
|
+
<img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
|
|
23
|
+
</a>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.18"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lupaxa-language-versions"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Local CLI companion to the Get Language Versions GitHub Action."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENCE" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "The Lupaxa Project" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
keywords = ["github-actions", "cli", "versions", "python", "node", "go"]
|
|
18
|
+
|
|
19
|
+
dependencies = [
|
|
20
|
+
"packaging>=24.2",
|
|
21
|
+
"requests>=2.32.5",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
classifiers = [
|
|
25
|
+
"Development Status :: 3 - Alpha",
|
|
26
|
+
"Environment :: Console",
|
|
27
|
+
"License :: OSI Approved :: MIT License",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
|
+
"Programming Language :: Python :: 3.14",
|
|
34
|
+
"Programming Language :: Python :: 3.15",
|
|
35
|
+
"Topic :: Software Development :: Build Tools",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/lupaxa-actions-toolbox/language-versions"
|
|
40
|
+
Repository = "https://github.com/lupaxa-actions-toolbox/language-versions"
|
|
41
|
+
Issues = "https://github.com/lupaxa-actions-toolbox/language-versions/issues"
|
|
42
|
+
"Get Language Versions Action" = "https://github.com/lupaxa-actions-toolbox/get-language-versions"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
language-versions = "lupaxa.language_versions.cli:main"
|
|
46
|
+
|
|
47
|
+
[project.optional-dependencies]
|
|
48
|
+
dev = [
|
|
49
|
+
"pytest>=8.0",
|
|
50
|
+
"pytest-cov>=5.0",
|
|
51
|
+
"ruff>=0.6.0",
|
|
52
|
+
"mypy>=1.12.0",
|
|
53
|
+
"hatch>=1.12.0",
|
|
54
|
+
"bump-my-version>=1.2.0",
|
|
55
|
+
"pip-audit>=2.7.0",
|
|
56
|
+
]
|
|
57
|
+
test = [
|
|
58
|
+
"pytest>=8.0",
|
|
59
|
+
"pytest-cov>=5.0",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
[tool.hatch.version]
|
|
63
|
+
path = "src/lupaxa/language_versions/version.py"
|
|
64
|
+
|
|
65
|
+
[tool.hatch.build.targets.sdist]
|
|
66
|
+
include = [
|
|
67
|
+
"src/**",
|
|
68
|
+
"README.md",
|
|
69
|
+
"LICENCE",
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.hatch.build.targets.wheel]
|
|
73
|
+
packages = ["src/lupaxa"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff]
|
|
76
|
+
line-length = 200
|
|
77
|
+
target-version = "py311"
|
|
78
|
+
|
|
79
|
+
[tool.ruff.lint]
|
|
80
|
+
select = ["E", "F", "I", "B", "S", "UP", "SIM", "C4", "ISC", "D", "ANN", "PT"]
|
|
81
|
+
ignore = [
|
|
82
|
+
"D200", "D201", "D202", "D203", "D204", "D205", "D206", "D207", "D208", "D209", "D210", "D211", "D212",
|
|
83
|
+
"ISC001",
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint.per-file-ignores]
|
|
87
|
+
"tests/**/*.py" = ["S101", "S104", "S105", "S106", "D", "ANN001", "ANN201"]
|
|
88
|
+
|
|
89
|
+
[tool.ruff.lint.pydocstyle]
|
|
90
|
+
convention = "numpy"
|
|
91
|
+
|
|
92
|
+
[tool.ruff.format]
|
|
93
|
+
quote-style = "double"
|
|
94
|
+
|
|
95
|
+
[tool.mypy]
|
|
96
|
+
python_version = "3.11"
|
|
97
|
+
files = ["src", "tests"]
|
|
98
|
+
mypy_path = "src"
|
|
99
|
+
explicit_package_bases = true
|
|
100
|
+
namespace_packages = true
|
|
101
|
+
warn_unused_configs = true
|
|
102
|
+
warn_return_any = true
|
|
103
|
+
warn_unused_ignores = true
|
|
104
|
+
disallow_untyped_defs = true
|
|
105
|
+
follow_imports = "normal"
|
|
106
|
+
ignore_missing_imports = true
|
|
107
|
+
|
|
108
|
+
[tool.pytest.ini_options]
|
|
109
|
+
addopts = "-ra -q --disable-warnings --cov=lupaxa.language_versions --cov-report=term-missing"
|
|
110
|
+
testpaths = ["tests"]
|
|
111
|
+
pythonpath = ["src"]
|
|
112
|
+
|
|
113
|
+
[tool.coverage.run]
|
|
114
|
+
source = ["lupaxa.language_versions"]
|
|
115
|
+
branch = true
|
|
116
|
+
|
|
117
|
+
[tool.coverage.report]
|
|
118
|
+
show_missing = true
|
|
119
|
+
skip_empty = true
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Command-line entry point for the local language-version lookup."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
from typing import NoReturn
|
|
9
|
+
|
|
10
|
+
from packaging.version import InvalidVersion
|
|
11
|
+
|
|
12
|
+
from lupaxa.language_versions.lookup import SOURCES, VersionLookupError, lookup
|
|
13
|
+
from lupaxa.language_versions.version import get_version
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _cell(text: str, width: int) -> str:
|
|
17
|
+
"""Return one padded table cell, including its side spaces."""
|
|
18
|
+
return f" {text.ljust(width)} "
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _pair_rule(left: str, middle: str, right: str, left_width: int, right_width: int) -> str:
|
|
22
|
+
"""Return a two-column box-drawing rule."""
|
|
23
|
+
return f"{left}{'─' * (left_width + 2)}{middle}{'─' * (right_width + 2)}{right}"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _pair_row(left: str, right: str, left_width: int, right_width: int) -> str:
|
|
27
|
+
"""Return one two-column table row."""
|
|
28
|
+
return f"│{_cell(left, left_width)}│{_cell(right, right_width)}│"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _span_row(text: str, width: int) -> str:
|
|
32
|
+
"""Return one row that spans both columns."""
|
|
33
|
+
return f"│{_cell(text, width)}│"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def format_report(
|
|
37
|
+
language: str, min_version: str, max_version: str, versions: list[str], *, include_prereleases: bool, highest_only: bool, remove_patch_version: bool, use_head: bool, max_versions: int
|
|
38
|
+
) -> str:
|
|
39
|
+
"""Return a table of the flags used and the matching versions."""
|
|
40
|
+
max_versions_text = "0 (every match)" if max_versions == 0 else str(max_versions)
|
|
41
|
+
rows = [
|
|
42
|
+
("language", language),
|
|
43
|
+
("min-version", min_version),
|
|
44
|
+
("max-version", max_version),
|
|
45
|
+
("max-versions", max_versions_text),
|
|
46
|
+
("include-prereleases", "yes" if include_prereleases else "no"),
|
|
47
|
+
("highest-only", "yes" if highest_only else "no"),
|
|
48
|
+
("remove-patch-version", "yes" if remove_patch_version else "no"),
|
|
49
|
+
("use-head", "yes" if use_head else "no"),
|
|
50
|
+
]
|
|
51
|
+
headers = ("Flag", "Value")
|
|
52
|
+
left_width = max(len(headers[0]), *(len(label) for label, _ in rows))
|
|
53
|
+
right_width = max(len(headers[1]), *(len(value) for _, value in rows))
|
|
54
|
+
span_width = left_width + right_width + 3
|
|
55
|
+
lines = [
|
|
56
|
+
_pair_rule("┌", "┬", "┐", left_width, right_width),
|
|
57
|
+
_pair_row(headers[0], headers[1], left_width, right_width),
|
|
58
|
+
_pair_rule("├", "┼", "┤", left_width, right_width),
|
|
59
|
+
]
|
|
60
|
+
lines.extend(_pair_row(label, value, left_width, right_width) for label, value in rows)
|
|
61
|
+
lines.append(_pair_rule("├", "┴", "┤", left_width, right_width))
|
|
62
|
+
lines.append(_span_row(f"Versions ({len(versions)})", span_width))
|
|
63
|
+
lines.append(f"├{'─' * (span_width + 2)}┤")
|
|
64
|
+
lines.extend(_span_row(version, span_width) for version in versions)
|
|
65
|
+
lines.append(f"└{'─' * (span_width + 2)}┘")
|
|
66
|
+
return "\n".join(lines)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _use_color() -> bool:
|
|
70
|
+
"""Return true when an error line should be printed in red."""
|
|
71
|
+
if os.environ.get("NO_COLOR"):
|
|
72
|
+
return False
|
|
73
|
+
if os.environ.get("FORCE_COLOR"):
|
|
74
|
+
return True
|
|
75
|
+
return sys.stderr.isatty()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _red(text: str) -> str:
|
|
79
|
+
"""Return text in red when the error stream is a colour terminal."""
|
|
80
|
+
if not _use_color():
|
|
81
|
+
return text
|
|
82
|
+
return f"\033[31m{text}\033[0m"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class LanguageVersionsParser(argparse.ArgumentParser):
|
|
86
|
+
"""Parser that leads invalid input with a red error, then the help."""
|
|
87
|
+
|
|
88
|
+
def error(self, message: str) -> NoReturn:
|
|
89
|
+
"""Print the error in red, then the help, and exit."""
|
|
90
|
+
print(_red(f"[ Error ] {message}"), file=sys.stderr)
|
|
91
|
+
print(file=sys.stderr)
|
|
92
|
+
self.print_help(sys.stderr)
|
|
93
|
+
self.exit(2)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def build_parser() -> LanguageVersionsParser:
|
|
97
|
+
"""Return the parser for the local companion command."""
|
|
98
|
+
description = "Local supporting tool for the Get Language Versions GitHub Action.\nThe workflow step remains lupaxa-actions-toolbox/get-language-versions."
|
|
99
|
+
parser = LanguageVersionsParser(prog="language-versions", formatter_class=argparse.RawDescriptionHelpFormatter, description=description)
|
|
100
|
+
parser.add_argument("language", choices=sorted(SOURCES), help="Language to query: go, node, nodejs, perl, php, python, or ruby")
|
|
101
|
+
parser.add_argument("--min-version", default="eol", help="Lowest major.minor, eol for the oldest supported release, or all")
|
|
102
|
+
parser.add_argument("--max-version", default="latest", help="Highest major.minor, or latest for no upper bound")
|
|
103
|
+
parser.add_argument("--max-versions", type=int, default=0, help="How many of the newest matching versions to print. 0 prints every match")
|
|
104
|
+
parser.add_argument("--include-prereleases", action="store_true", help="Include prerelease versions. Cannot be combined with --remove-patch-version")
|
|
105
|
+
parser.add_argument("--highest-only", action="store_true", help="Print only the highest matching version")
|
|
106
|
+
parser.add_argument("--remove-patch-version", action="store_true", help="Print major.minor only. Cannot be combined with --include-prereleases")
|
|
107
|
+
parser.add_argument("--use-head", action="store_true", help="Read the default branch instead of the latest release. Ignored for PHP")
|
|
108
|
+
parser.add_argument("--version", action="version", version=get_version())
|
|
109
|
+
return parser
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def main(argv: list[str] | None = None) -> None:
|
|
113
|
+
"""Look up versions and print the flags used with the matching versions."""
|
|
114
|
+
parser = build_parser()
|
|
115
|
+
args = parser.parse_args(argv)
|
|
116
|
+
try:
|
|
117
|
+
versions = lookup(
|
|
118
|
+
args.language,
|
|
119
|
+
args.min_version,
|
|
120
|
+
args.max_version,
|
|
121
|
+
include_prereleases=args.include_prereleases,
|
|
122
|
+
highest_only=args.highest_only,
|
|
123
|
+
remove_patch_version=args.remove_patch_version,
|
|
124
|
+
use_head=args.use_head,
|
|
125
|
+
max_versions=args.max_versions,
|
|
126
|
+
)
|
|
127
|
+
except (VersionLookupError, InvalidVersion) as exc:
|
|
128
|
+
parser.error(str(exc))
|
|
129
|
+
else:
|
|
130
|
+
print(
|
|
131
|
+
format_report(
|
|
132
|
+
args.language,
|
|
133
|
+
args.min_version,
|
|
134
|
+
args.max_version,
|
|
135
|
+
versions,
|
|
136
|
+
include_prereleases=args.include_prereleases,
|
|
137
|
+
highest_only=args.highest_only,
|
|
138
|
+
remove_patch_version=args.remove_patch_version,
|
|
139
|
+
use_head=args.use_head,
|
|
140
|
+
max_versions=args.max_versions,
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if __name__ == "__main__":
|
|
146
|
+
main()
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"""Resolve the same runtime versions as the Get Language Versions action."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
from packaging.version import InvalidVersion, Version
|
|
9
|
+
from packaging.version import parse as parse_version
|
|
10
|
+
|
|
11
|
+
REQUEST_TIMEOUT = 5
|
|
12
|
+
MAX_VERSION = parse_version("99999")
|
|
13
|
+
MIN_VERSION = parse_version("0")
|
|
14
|
+
|
|
15
|
+
_NODE_SOURCE = {
|
|
16
|
+
"releases_url": "https://github.com/actions/node-versions/releases/latest/",
|
|
17
|
+
"head_branch": "main",
|
|
18
|
+
"versions_url": "https://raw.githubusercontent.com/actions/node-versions/LATEST_TAG/versions-manifest.json",
|
|
19
|
+
"eol_url": "https://endoflife.date/api/nodejs.json",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SOURCES: dict[str, dict[str, str]] = {
|
|
23
|
+
"go": {
|
|
24
|
+
"releases_url": "https://github.com/actions/go-versions/releases/latest/",
|
|
25
|
+
"head_branch": "main",
|
|
26
|
+
"versions_url": "https://raw.githubusercontent.com/actions/go-versions/LATEST_TAG/versions-manifest.json",
|
|
27
|
+
"eol_url": "https://endoflife.date/api/go.json",
|
|
28
|
+
},
|
|
29
|
+
"node": _NODE_SOURCE,
|
|
30
|
+
"nodejs": _NODE_SOURCE,
|
|
31
|
+
"perl": {
|
|
32
|
+
"releases_url": "https://github.com/shogo82148/actions-setup-perl/releases/latest/",
|
|
33
|
+
"head_branch": "main",
|
|
34
|
+
"versions_url": "https://raw.githubusercontent.com/shogo82148/actions-setup-perl/LATEST_TAG/src/versions/perl.json",
|
|
35
|
+
"eol_url": "https://endoflife.date/api/perl.json",
|
|
36
|
+
},
|
|
37
|
+
"php": {
|
|
38
|
+
"versions_url": "https://phpreleases.com/api/releases/",
|
|
39
|
+
"eol_url": "https://endoflife.date/api/php.json",
|
|
40
|
+
},
|
|
41
|
+
"python": {
|
|
42
|
+
"releases_url": "https://github.com/actions/python-versions/releases/latest/",
|
|
43
|
+
"head_branch": "main",
|
|
44
|
+
"versions_url": "https://raw.githubusercontent.com/actions/python-versions/LATEST_TAG/versions-manifest.json",
|
|
45
|
+
"eol_url": "https://endoflife.date/api/python.json",
|
|
46
|
+
},
|
|
47
|
+
"ruby": {
|
|
48
|
+
"releases_url": "https://github.com/ruby/setup-ruby/releases/latest/",
|
|
49
|
+
"head_branch": "master",
|
|
50
|
+
"versions_url": "https://raw.githubusercontent.com/ruby/setup-ruby/LATEST_TAG/ruby-builder-versions.json",
|
|
51
|
+
"eol_url": "https://endoflife.date/api/ruby.json",
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class VersionLookupError(Exception):
|
|
57
|
+
"""The language lookup could not return versions."""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def fetch_json(url: str) -> list[object] | dict[str, object]:
|
|
61
|
+
"""Return the JSON object or list from a URL."""
|
|
62
|
+
response = requests.get(url, timeout=REQUEST_TIMEOUT)
|
|
63
|
+
response.raise_for_status()
|
|
64
|
+
body = response.json()
|
|
65
|
+
if isinstance(body, list):
|
|
66
|
+
return body
|
|
67
|
+
if isinstance(body, dict):
|
|
68
|
+
return body
|
|
69
|
+
message = f"Unexpected JSON from {url}"
|
|
70
|
+
raise TypeError(message)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def latest_release_tag(releases_url: str) -> str:
|
|
74
|
+
"""Return the tag from the redirected GitHub latest-release URL."""
|
|
75
|
+
response = requests.get(releases_url, timeout=REQUEST_TIMEOUT)
|
|
76
|
+
response.raise_for_status()
|
|
77
|
+
return response.url.rstrip("/").split("/")[-1]
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def version_list_url(language: str, *, use_head: bool) -> str:
|
|
81
|
+
"""Return the URL that lists versions for a language."""
|
|
82
|
+
source = SOURCES[language]
|
|
83
|
+
versions_url = source["versions_url"]
|
|
84
|
+
if use_head and "head_branch" in source:
|
|
85
|
+
return versions_url.replace("LATEST_TAG", source["head_branch"])
|
|
86
|
+
if "releases_url" in source:
|
|
87
|
+
return versions_url.replace("LATEST_TAG", latest_release_tag(source["releases_url"]))
|
|
88
|
+
return versions_url
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def version_records(payload: list[object] | dict[str, object]) -> list[dict[str, object]]:
|
|
92
|
+
"""Return payload entries that are JSON objects."""
|
|
93
|
+
if not isinstance(payload, list):
|
|
94
|
+
message = "Expected a list of version records"
|
|
95
|
+
raise TypeError(message)
|
|
96
|
+
records: list[dict[str, object]] = []
|
|
97
|
+
for item in payload:
|
|
98
|
+
if not isinstance(item, dict):
|
|
99
|
+
message = "Expected a version record"
|
|
100
|
+
raise TypeError(message)
|
|
101
|
+
records.append(item)
|
|
102
|
+
return records
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def supported_minimum(language: str) -> Version:
|
|
106
|
+
"""Return the oldest cycle that endoflife.date still marks as supported."""
|
|
107
|
+
minimum = MAX_VERSION
|
|
108
|
+
for release in version_records(fetch_json(SOURCES[language]["eol_url"])):
|
|
109
|
+
try:
|
|
110
|
+
cycle = parse_version(str(release["cycle"]))
|
|
111
|
+
except InvalidVersion:
|
|
112
|
+
continue
|
|
113
|
+
|
|
114
|
+
eol = release["eol"]
|
|
115
|
+
if eol is True:
|
|
116
|
+
continue
|
|
117
|
+
if eol is False:
|
|
118
|
+
if cycle < minimum:
|
|
119
|
+
minimum = cycle
|
|
120
|
+
continue
|
|
121
|
+
if datetime.date.today() < datetime.date.fromisoformat(str(eol)):
|
|
122
|
+
minimum = cycle
|
|
123
|
+
return minimum
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def resolve_minimum(min_version: str, language: str) -> Version:
|
|
127
|
+
"""Resolve a min-version input to a comparable version."""
|
|
128
|
+
normalised = min_version.upper()
|
|
129
|
+
if normalised == "EOL":
|
|
130
|
+
return supported_minimum(language)
|
|
131
|
+
if normalised == "ALL":
|
|
132
|
+
return MIN_VERSION
|
|
133
|
+
return parse_version(min_version)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def resolve_maximum(max_version: str) -> Version:
|
|
137
|
+
"""Resolve a max-version input to a comparable version."""
|
|
138
|
+
if max_version.upper() == "LATEST":
|
|
139
|
+
return MAX_VERSION
|
|
140
|
+
return parse_version(max_version)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def is_version(value: str) -> bool:
|
|
144
|
+
"""Return true when value parses as a version."""
|
|
145
|
+
try:
|
|
146
|
+
parse_version(value)
|
|
147
|
+
except InvalidVersion:
|
|
148
|
+
return False
|
|
149
|
+
return True
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def extract_versions(language: str, payload: list[object] | dict[str, object]) -> list[str]:
|
|
153
|
+
"""Pull version strings out of a language-specific payload."""
|
|
154
|
+
if language == "php":
|
|
155
|
+
candidates = [f"{item['major']}.{item['minor']}.{item['release']}" for item in version_records(payload)]
|
|
156
|
+
elif language == "ruby":
|
|
157
|
+
if not isinstance(payload, dict):
|
|
158
|
+
message = "Expected a Ruby version object"
|
|
159
|
+
raise TypeError(message)
|
|
160
|
+
ruby_versions = payload["ruby"]
|
|
161
|
+
if not isinstance(ruby_versions, list):
|
|
162
|
+
message = "Expected a list of Ruby versions"
|
|
163
|
+
raise TypeError(message)
|
|
164
|
+
candidates = [str(version) for version in ruby_versions]
|
|
165
|
+
else:
|
|
166
|
+
candidates = [str(item["version"]) for item in version_records(payload)]
|
|
167
|
+
return [version for version in candidates if is_version(version)]
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def remember_highest(chosen: dict[Version, str], version: str, minimum: Version, maximum: Version) -> None:
|
|
171
|
+
"""Keep the highest version string for each major.minor inside the range."""
|
|
172
|
+
major_minor = parse_version(".".join(version.split(".")[:2]))
|
|
173
|
+
if not minimum <= major_minor <= maximum:
|
|
174
|
+
return
|
|
175
|
+
current = chosen.get(major_minor)
|
|
176
|
+
if current is None or parse_version(current) < parse_version(version):
|
|
177
|
+
chosen[major_minor] = version
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def select_versions(versions: list[str], minimum: Version, maximum: Version, *, include_prereleases: bool, remove_patch_version: bool) -> list[str]:
|
|
181
|
+
"""Filter, collapse, and sort versions the same way the action does."""
|
|
182
|
+
chosen: dict[Version, str] = {}
|
|
183
|
+
for version in versions:
|
|
184
|
+
if not is_version(version):
|
|
185
|
+
continue
|
|
186
|
+
if not include_prereleases and parse_version(version).is_prerelease:
|
|
187
|
+
continue
|
|
188
|
+
if remove_patch_version:
|
|
189
|
+
version = ".".join(version.split(".")[:2])
|
|
190
|
+
remember_highest(chosen, version, minimum, maximum)
|
|
191
|
+
return sorted(chosen.values(), key=parse_version)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def limit_versions(versions: list[str], *, highest_only: bool, max_versions: int) -> list[str]:
|
|
195
|
+
"""Apply the same highest-only and max-versions cuts as the action."""
|
|
196
|
+
if not versions:
|
|
197
|
+
message = "No versions matched"
|
|
198
|
+
raise VersionLookupError(message)
|
|
199
|
+
if highest_only:
|
|
200
|
+
return [versions[-1]]
|
|
201
|
+
if max_versions > 0:
|
|
202
|
+
return versions[-max_versions:]
|
|
203
|
+
return list(versions)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def lookup(
|
|
207
|
+
language: str,
|
|
208
|
+
min_version: str = "eol",
|
|
209
|
+
max_version: str = "latest",
|
|
210
|
+
*,
|
|
211
|
+
include_prereleases: bool = False,
|
|
212
|
+
highest_only: bool = False,
|
|
213
|
+
remove_patch_version: bool = False,
|
|
214
|
+
use_head: bool = False,
|
|
215
|
+
max_versions: int = 0,
|
|
216
|
+
) -> list[str]:
|
|
217
|
+
"""Return the versions the Get Language Versions action would publish."""
|
|
218
|
+
language_key = language.lower()
|
|
219
|
+
if language_key not in SOURCES:
|
|
220
|
+
options = ", ".join(SOURCES)
|
|
221
|
+
message = f"{language} is not a valid option. Valid options are: {options}"
|
|
222
|
+
raise VersionLookupError(message)
|
|
223
|
+
if remove_patch_version and include_prereleases:
|
|
224
|
+
message = "include-prereleases cannot be combined with remove-patch-version"
|
|
225
|
+
raise VersionLookupError(message)
|
|
226
|
+
if max_versions < 0:
|
|
227
|
+
message = "max-versions must be 0 or greater"
|
|
228
|
+
raise VersionLookupError(message)
|
|
229
|
+
|
|
230
|
+
payload = fetch_json(version_list_url(language_key, use_head=use_head))
|
|
231
|
+
versions = select_versions(
|
|
232
|
+
extract_versions(language_key, payload),
|
|
233
|
+
resolve_minimum(min_version, language_key),
|
|
234
|
+
resolve_maximum(max_version),
|
|
235
|
+
include_prereleases=include_prereleases,
|
|
236
|
+
remove_patch_version=remove_patch_version,
|
|
237
|
+
)
|
|
238
|
+
return limit_versions(versions, highest_only=highest_only, max_versions=max_versions)
|