Skip to content

Commit e7ffe9b

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

File tree

3 files changed

+67
-22
lines changed

3 files changed

+67
-22
lines changed

.github/workflows/publish.yaml

Lines changed: 62 additions & 20 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 📦
1311
runs-on: ubuntu-latest
14-
environment:
15-
name: pypi
16-
url: https://pypi.org/p/i18ntools
17-
permissions:
18-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
1912
steps:
2013
- uses: actions/checkout@v6
14+
with:
15+
persist-credentials: false
2116
- name: Set up Python
2217
uses: actions/setup-python@v6
2318
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
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
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: pypi
43+
url: https://pypi.org/p/i18ntools
44+
permissions:
45+
id-token: write # IMPORTANT: mandatory for trusted publishing
46+
steps:
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
73+
with:
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"

0 commit comments

Comments
 (0)