Skip to content

Commit 7edd691

Browse files
⬆️ CI/CD: Refactor publish workflows to use reusable actions
1 parent 5300a8f commit 7edd691

File tree

2 files changed

+62
-39
lines changed

2 files changed

+62
-39
lines changed

.github/workflows/python-publish-pypi-test.yml

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 📦 Package PyPI-Test
22

33
on:
44
push:
5-
branches: [ "pypi" ]
5+
branches: ["pypi"]
66

77
permissions:
88
contents: write
@@ -20,30 +20,24 @@ jobs:
2020
secrets: inherit
2121

2222
deploy:
23+
name: Deploy to TestPyPI
2324
needs: [test, code-quality]
2425
runs-on: ubuntu-latest
2526

2627
steps:
27-
- uses: actions/checkout@v4
28-
with:
29-
repo-token: ${{ secrets.GITHUB_TOKEN }}
30-
31-
- name: ⚙️ Set up Python 3.11
32-
uses: actions/setup-python@v5
33-
with:
34-
python-version: "3.11"
35-
36-
- name: ⚙️ Install dependencies
37-
run: |
38-
python -m pip install --upgrade pip
39-
pip install build --no-cache-dir
40-
41-
- name: 📦 Build Package
42-
run: python -m build
43-
44-
- name: 📦 Publish Package to Test PyPI
45-
uses: pypa/gh-action-pypi-publish@release/v1
46-
with:
47-
repository-url: https://test.pypi.org/legacy/
48-
skip-existing: true
49-
verbose: true
28+
- name: 📥 Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: 📦 Build Package
34+
uses: ./.github/actions/build-package
35+
with:
36+
python-version: "3.11"
37+
38+
- name: 📦 Publish Package to Test PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
with:
41+
repository-url: https://test.pypi.org/legacy/
42+
skip-existing: true
43+
verbose: true

.github/workflows/python-publish-pypi.yml

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,64 @@ on:
55
types: [published]
66

77
permissions:
8-
contents: read
8+
contents: write
99
id-token: write
1010

1111
jobs:
12+
update-version:
13+
name: Update Version Files
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: 📥 Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
ref: ${{ github.event.release.target_commitish }}
22+
23+
- name: 🔍 Extract version
24+
uses: ./.github/actions/extract-version
25+
id: extract_version
26+
with:
27+
tag: ${{ github.event.release.tag_name }}
28+
29+
- name: 📝 Update version files
30+
uses: ./.github/actions/update-version
31+
with:
32+
version: ${{ steps.extract_version.outputs.version }}
33+
34+
- name: 💾 Commit and push
35+
uses: ./.github/actions/commit-push
36+
with:
37+
message: "📦 PyPI: Update version to ${{ steps.extract_version.outputs.version }}"
38+
files: "LAST_VERSION pyproject.toml mkdocs_simple_blog/__init__.py"
39+
branch: ${{ github.event.release.target_commitish }}
40+
1241
test:
1342
name: Run Tests
43+
needs: [update-version]
1444
uses: ./.github/workflows/test.yml
1545
secrets: inherit
1646

1747
code-quality:
1848
name: Code Quality Checks
49+
needs: [update-version]
1950
uses: ./.github/workflows/code-quality.yml
2051
secrets: inherit
2152

2253
deploy:
23-
needs: [test, code-quality]
54+
name: Deploy to PyPI
55+
needs: [update-version, test, code-quality]
2456
runs-on: ubuntu-latest
2557

2658
steps:
27-
- uses: actions/checkout@v4
28-
- name: ⚙️ Set up Python 3.10
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: "3.10"
32-
- name: ⚙️ Install dependencies
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install build --no-cache-dir
36-
- name: 📦 Build Package
37-
run: python -m build
38-
- name: 📦 Publish Package to PyPI
39-
uses: pypa/gh-action-pypi-publish@release/v1
59+
- name: 📥 Checkout code
60+
uses: actions/checkout@v4
61+
62+
- name: 📦 Build Package
63+
uses: ./.github/actions/build-package
64+
with:
65+
python-version: "3.10"
66+
67+
- name: 📦 Publish Package to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)