Skip to content

Commit b6952be

Browse files
authored
feat: add workflow and instructions to build and publish api_auth (#496)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent f7e8380 commit b6952be

4 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build aboutcode.api_auth Python distributions and publish on PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "aboutcode.api_auth/*"
8+
9+
jobs:
10+
build:
11+
name: Build and publish library to PyPI
12+
runs-on: ubuntu-24.04
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false # do not keep the token around
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
23+
with:
24+
python-version: 3.14
25+
26+
- name: Install flot
27+
run: python -m pip install flot --user
28+
29+
- name: Build a binary wheel and a source tarball
30+
run: python -m flot --pyproject pipeline-pyproject.toml --sdist --wheel --output-dir dist/
31+
32+
- name: Upload package distributions as GitHub workflow artifacts
33+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
34+
with:
35+
name: python-package-distributions
36+
path: dist/
37+
38+
# Only set the id-token: write permission in the job that does publishing, not globally.
39+
# Also, separate building from publishing — this makes sure that any scripts
40+
# maliciously injected into the build or test environment won't be able to elevate
41+
# privileges while flying under the radar.
42+
pypi-publish:
43+
name: Upload package distributions to PyPI
44+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
45+
needs:
46+
- build
47+
runs-on: ubuntu-24.04
48+
environment:
49+
name: pypi
50+
url: https://pypi.org/p/aboutcode.api_auth
51+
permissions:
52+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
53+
54+
steps:
55+
- name: Download all the dists
56+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
57+
with:
58+
name: python-package-distributions
59+
path: dist/
60+
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

aboutcode/api_auth/RELEASE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Release instructions for `aboutcode.api_auth`
2+
3+
### Automated release workflow
4+
5+
- Create a new `aboutcode.api_auth-release-x.x.x` branch
6+
- Update the version in:
7+
- `api_auth-pyproject.toml`
8+
- `aboutcode/api_auth/__init__.py`
9+
- Commit and push this branch
10+
- Create a PR and merge once approved
11+
- Tag and push to trigger the `publish-pypi-release-aboutcode-api-auth.yml` workflow
12+
that takes care of building the distribution archives and upload those to pypi::
13+
```
14+
VERSION=x.x.x # <- Set the new version here
15+
TAG=aboutcode.api_auth/$VERSION
16+
git tag -a $TAG -m ""
17+
git push origin $TAG
18+
```
19+
20+
### Manual build
21+
22+
```
23+
cd dejacode
24+
source .venv/bin/activate
25+
pip install flot
26+
flot --pyproject api_auth-pyproject.toml --sdist --wheel --output-dir dist/
27+
```
28+
29+
The distribution archives will be available in the local `dist/` directory.

aboutcode/api_auth/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from rest_framework.authentication import TokenAuthentication
2020
from rest_framework.exceptions import AuthenticationFailed
2121

22+
__version__ = "0.1.0"
23+
2224

2325
class AbstractAPIToken(models.Model):
2426
"""

api_auth-pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[build-system]
2+
requires = ["flot"]
3+
build-backend = "flot.buildapi"
4+
5+
[project]
6+
name = "aboutcode.api_auth"
7+
version = "0.1.0"
8+
description = ""
9+
license = { text = "Apache-2.0" }
10+
readme = "aboutcode/api_auth/README.md"
11+
requires-python = ">=3.11"
12+
authors = [ { name = "nexB. Inc. and others", email = "info@aboutcode.org" } ]
13+
keywords = [
14+
"open source",
15+
"api",
16+
"authentication",
17+
]
18+
classifiers = [
19+
"Development Status :: 4 - Beta",
20+
"Intended Audience :: Developers",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
26+
"Programming Language :: Python :: 3.14",
27+
"Topic :: Software Development",
28+
"Topic :: Utilities",
29+
]
30+
31+
[project.urls]
32+
Homepage = "https://github.com/aboutcode-org/dejacode"
33+
Documentation = "https://dejacode.readthedocs.io/"
34+
Repository = "https://github.com/aboutcode-org/dejacode/tree/main/aboutcode/api_auth"
35+
Issues = "https://github.com/aboutcode-org/dejacode/issues"
36+
37+
[tool.flot]
38+
includes = [
39+
"aboutcode/api_auth/*",
40+
]
41+
metadata_files = [
42+
"LICENSE",
43+
"NOTICE",
44+
]

0 commit comments

Comments
 (0)