Skip to content

Commit f7b99ee

Browse files
committed
Add release workflow
- The workflow does no release if a valid environment is not selected. - By default, the workflow will create a .devN release using the current uap-core master.
1 parent 4dcf29c commit f7b99ee

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish Python distribution to PyPI and TestPyPI
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "uap-core ref to release"
8+
type: string
9+
environment:
10+
description: "environment to release for (testpypy or pypy)"
11+
type: environment
12+
13+
jobs:
14+
build:
15+
name: Build distribution
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: true
22+
fetch-depth: 0
23+
- name: update core
24+
# needs to detach because we can update to a tag
25+
run: git -C uap-core switch --detach ${{ inputs.tag || 'master' }}
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.x"
30+
31+
- name: Install pypa/build
32+
run: python3 -m pip install build --user
33+
- name: Build a binary wheel and a source tarball
34+
run: python3 -m build -w ua-parser-builtins
35+
- run: mv ua-parser-builtins/dist .
36+
- name: Store the distribution packages
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: python-package-distributions
40+
path: dist/
41+
42+
publish-to-testpypi:
43+
name: Publish to TestPyPI
44+
if: ${{ github.event.inputs.environment == 'testpypi' }}
45+
needs:
46+
- build
47+
runs-on: ubuntu-latest
48+
49+
environment:
50+
name: testpypi
51+
url: https://test.pypi.org/p/ua-parser-builtins
52+
53+
permissions:
54+
id-token: write
55+
56+
steps:
57+
- name: Download all the dists
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: python-package-distributions
61+
path: dist/
62+
- name: Publish
63+
uses: pypa/gh-action-pypi-publish@release/v1
64+
with:
65+
repository-url: https://test.pypi.org/legacy/
66+
67+
publish-to-pypi:
68+
name: publish
69+
if: ${{ inputs.environment == 'pypi' }}
70+
needs:
71+
- build
72+
runs-on: ubuntu-latest
73+
environment:
74+
name: pypi
75+
url: https://pypi.org/p/ua-parser-builtins
76+
permissions:
77+
id-token: write
78+
79+
steps:
80+
- name: Download all the dists
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: python-package-distributions
84+
path: dist/
85+
- name: Publish
86+
uses: pypa/gh-action-pypi-publish@release/v1

ua-parser-builtins/pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,32 @@ name = "ua-parser-builtins"
77
description = "Precompiled rules for User Agent Parser"
88
readme = "README.md"
99
dependencies = ["ua-parser"]
10+
requires-python = ">=3.9"
1011
license = {text = "Apache 2.0"}
1112
urls = {repository = "https://github.com/ua-parser/uap-python"}
1213
dynamic = ["version"]
14+
maintainers = [
15+
{ name = "masklinn", email = "[email protected]" }
16+
]
17+
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Environment :: Web Environment",
21+
"Intended Audience :: Developers",
22+
"Operating System :: OS Independent",
23+
"License :: OSI Approved :: Apache Software License",
24+
"Programming Language :: Python",
25+
"Topic :: Internet :: WWW/HTTP",
26+
"Topic :: Software Development :: Libraries :: Python Modules",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3.9",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: Implementation :: CPython",
33+
"Programming Language :: Python :: Implementation :: PyPy",
34+
# "Programming Language :: Python :: Implementation :: GraalPy",
35+
]
1336

1437
[tool.hatch.build.hooks.custom]
1538

0 commit comments

Comments
 (0)