Skip to content

Commit

Permalink
Merge pull request #36 from wael-sudo2/update/workflow
Browse files Browse the repository at this point in the history
Update publish-to-test-pypi.yml
  • Loading branch information
wael-sudo2 authored Sep 29, 2024
2 parents f484028 + c41c58d commit f4ffea8
Showing 1 changed file with 44 additions and 24 deletions.
68 changes: 44 additions & 24 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,49 @@ jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install pypa/build
run: python -m pip install build

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Bump version
run: |
current_version=$(grep -oP '(?<=version=").*(?=")' setup.py)
new_version=$(echo $current_version | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
sed -i "s/version=\"$current_version\"/version=\"$new_version\"/" setup.py
- name: Build a binary wheel and a source tarball
run: python -m build

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
continue-on-error: true

- name: Publish distribution 📦 to PyPI
if: github.ref == 'refs/heads/main' && success()
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create GitHub Release
if: github.ref == 'refs/heads/main' && success()
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.bump_version.outputs.new_version }}
release_name: Release ${{ steps.bump_version.outputs.new_version }}
draft: false
prerelease: false

0 comments on commit f4ffea8

Please sign in to comment.