Skip to content

Commit 67c9582

Browse files
committed
Update GitHub Actions publish workflow
1 parent db98cc3 commit 67c9582

File tree

4 files changed

+69
-24
lines changed

4 files changed

+69
-24
lines changed

.github/workflows/publish.yaml

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,74 @@
11
# kics-scan disable=a88baa34-e2ad-44ea-ad6f-8cac87bc7c71,555ab8f9-2001-455e-a077-f2d0f41e2fb9
22
---
3-
name: Upload Python Package
3+
name: Upload Python Package to PyPI and TestPyPI
44
permissions: read-all
55

6-
on:
7-
release:
8-
types: [published]
6+
on: push
97

108
jobs:
11-
pypi-publish:
12-
name: Upload release to PyPI
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
persist-credentials: false
16+
- name: Set up Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.x"
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--user
26+
- name: Build a binary wheel and a source tarball
27+
run: python3 -m build
28+
- name: Store the distribution packages
29+
uses: actions/upload-artifact@v6
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
34+
publish-to-pypi:
35+
name: >-
36+
Publish Python 🐍 distribution 📦 to PyPI
37+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
38+
needs:
39+
- build
1340
runs-on: ubuntu-latest
1441
environment:
1542
name: pypi
1643
url: https://pypi.org/p/i18ntools
1744
permissions:
18-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
45+
id-token: write # IMPORTANT: mandatory for trusted publishing
1946
steps:
20-
- uses: actions/checkout@v6
21-
- name: Set up Python
22-
uses: actions/setup-python@v6
47+
- name: Download all the dists
48+
uses: actions/download-artifact@v6
49+
with:
50+
name: python-package-distributions
51+
path: dist/
52+
- name: Publish distribution 📦 to PyPI
53+
uses: pypa/gh-action-pypi-publish@release/v1
54+
55+
publish-to-testpypi:
56+
name: Publish Python 🐍 distribution 📦 to TestPyPI
57+
needs:
58+
- build
59+
runs-on: ubuntu-latest
60+
environment:
61+
name: testpypi
62+
url: https://test.pypi.org/p/java-properties-i18n-translation
63+
permissions:
64+
id-token: write # IMPORTANT: mandatory for trusted publishing
65+
steps:
66+
- name: Download all the dists
67+
uses: actions/download-artifact@v6
68+
with:
69+
name: python-package-distributions
70+
path: dist/
71+
- name: Publish distribution 📦 to TestPyPI
72+
uses: pypa/gh-action-pypi-publish@release/v1
2373
with:
24-
python-version: '3.x'
25-
- name: Install dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install build
29-
- name: Build package
30-
run: python -m build
31-
- name: Publish package distributions to PyPI
32-
uses: pypa/gh-action-pypi-publish@v1.11.0
74+
repository-url: https://test.pypi.org/legacy/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Thumbs.db
22
.DS_Store
33
.gradle
44
build/
5+
dist/
56
out/
67
logs/
78
node_modules/

DEPLOYING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
When we are ready to release a new version of the i18ntools package, we update the version number in [pyproject.toml](https://github.com/hypercision/i18ntools/blob/481a33fcd069b4f35c7293ac082f7115f6b28432/pyproject.toml#L3),
44
commit the change on the `main` branch, and push the commit to GitHub.
55

6+
Then we push a new tag to GitHub i.e. `v0.1.0`. This will trigger a GitHub actions workflow to publish the package to the [Python Package Index (PyPI)](https://pypi.org/project/i18ntools/).
7+
68
Then we create a new [release in GitHub](https://github.com/hypercision/i18ntools/releases):
79
- Click "Draft a new release"
810
- Title the release the new version number i.e. "v0.1.0"
9-
- Click "Choose a tag" and enter the new version number (i.e. "v0.1.0") to create a new tag
10-
- Then click "Publish release" and a GitHub actions workflow will be triggered to publish the package to the [Python Package Index (PyPI)](https://pypi.org/project/i18ntools/)
11+
- Click "Choose a tag" and enter the newly created tag.
12+
- Then click "Publish release"

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ authors = [
99
dependencies = [
1010
"requests",
1111
]
12-
license = { file="LICENSE" }
12+
license = "MIT"
13+
license-files = ["LICEN[CS]E*"]
1314
requires-python = ">=3.10"
1415
classifiers = [
1516
"Programming Language :: Python :: 3",
@@ -18,7 +19,6 @@ classifiers = [
1819
"Programming Language :: Python :: 3.12",
1920
"Programming Language :: Python :: 3.13",
2021
"Programming Language :: Python :: 3.14",
21-
"License :: OSI Approved :: MIT License",
2222
"Operating System :: OS Independent",
2323
"Development Status :: 5 - Production/Stable",
2424
]
@@ -34,7 +34,7 @@ test = [
3434
]
3535

3636
[build-system]
37-
requires = ["setuptools>=61.0"]
37+
requires = ["setuptools>=73.0"]
3838
build-backend = "setuptools.build_meta"
3939

4040
[tool.setuptools.packages.find]

0 commit comments

Comments
 (0)