Skip to content

Commit 6bc84f2

Browse files
Copilotdobairoland
authored andcommitted
ci(github): publish releases with pypa/gh-action-pypi-publish
1 parent 2cd044b commit 6bc84f2

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

.github/workflows/dev_release_esptool_pypi.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ jobs:
1414

1515
if: startsWith(github.ref, 'refs/tags/') && contains(github.ref_name, 'dev')
1616

17+
environment:
18+
name: pypi
19+
url: https://pypi.org/p/esptool
20+
21+
permissions:
22+
id-token: write
23+
1724
steps:
1825
- uses: actions/checkout@master
1926
- name: Set up Python 3.13
@@ -23,18 +30,15 @@ jobs:
2330
- name: Install dependencies
2431
run: |
2532
python -m pip install --upgrade pip
26-
python -m pip install twine build
33+
python -m pip install build
2734
2835
- name: Create development release ${{ github.ref_name }}
29-
env:
30-
TWINE_USERNAME: __token__
31-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
32-
TWINE_NON_INTERACTIVE: true
3336
run: |
3437
python ci/patch_dev_release.py --version ${{ github.ref_name }} esptool/__init__.py
3538
git diff
36-
python -m pip download esptool==$(python setup.py -V) && echo "Version ${{ github.ref_name }} already published, skipping..." && exit 1
37-
38-
echo "Packaging and publishing new esptool development release: ${{ github.ref_name }}"
39+
echo "Packaging esptool development release: ${{ github.ref_name }}"
3940
python -m build --sdist
40-
twine upload dist/*
41+
- name: Publish package to PyPI
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
with:
44+
skip-existing: true

.github/workflows/release_esptool_pypi.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ jobs:
1111

1212
runs-on: ubuntu-latest
1313

14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/esptool
17+
18+
permissions:
19+
id-token: write
20+
1421
steps:
1522
- uses: actions/checkout@master
1623
- name: Set up Python 3.13
@@ -20,20 +27,12 @@ jobs:
2027
- name: Install dependencies
2128
run: |
2229
python -m pip install --upgrade pip
23-
pip install twine build
24-
- name: Build and upload esptool ${{ github.event.release.tag_name }}
25-
env:
26-
TWINE_USERNAME: __token__
27-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
30+
pip install build
31+
- name: Build esptool ${{ github.event.release.tag_name }}
2832
run: |
29-
PUBLISHED_VERSION=$(curl https://pypi.org/pypi/esptool/json 2>/dev/null | jq -r '.info.version')
30-
CURRENT_VERSION=$(python setup.py --version 2>/dev/null)
31-
32-
if [ "$PUBLISHED_VERSION" == "$CURRENT_VERSION" ]; then
33-
echo "Version ${PUBLISHED_VERSION} already published, skipping..."
34-
exit 1
35-
else
36-
echo "Packaging and publishing new esptool version: ${CURRENT_VERSION}"
37-
python -m build --sdist
38-
twine upload dist/*
39-
fi
33+
echo "Packaging esptool version: $(python setup.py --version 2>/dev/null)"
34+
python -m build --sdist
35+
- name: Publish package to PyPI
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
skip-existing: true

0 commit comments

Comments
 (0)