Skip to content

Commit

Permalink
Refactor GitHub Actions workflow for PyPI publishing: remove release …
Browse files Browse the repository at this point in the history
…check step, handle missing PyPI version, and add Python 3.13 support.
  • Loading branch information
fox-techniques committed Jan 5, 2025
1 parent a94519b commit be6debc
Showing 1 changed file with 4 additions and 43 deletions.
47 changes: 4 additions & 43 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,12 @@ jobs:
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
- name: Check if GitHub Release Exists
id: check_release
run: |
if gh release view ${{ steps.extract_tag.outputs.tag_name }} > /dev/null 2>&1; then
echo "skip=true" >> "$GITHUB_ENV"
exit 1
else
echo "skip=false" >> "$GITHUB_ENV"
fi
- name: Fetch PyPI Version
id: check_pypi
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_previous_version=$(echo $response | jq -r '.releases | keys_unsorted | sort | .[-1]')
if [ -z "$latest_previous_version" ]; then
echo "Package not found on PyPI."
latest_previous_version=$(echo "$response" | jq -r '.releases | keys_unsorted | sort | .[-1]' || echo "0.0.0")
if [ -z "$latest_previous_version" ] || [ "$latest_previous_version" == "null" ]; then
latest_previous_version="0.0.0"
fi
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
Expand All @@ -71,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -127,6 +116,7 @@ jobs:
permissions:
contents: read
actions: write
id-token: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
Expand All @@ -138,32 +128,3 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}

github_release:
name: Create GitHub Release
needs: [details, setup_and_build]
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Ensure dist is not empty
run: |
if [ -z "$(ls -A dist)" ]; then
echo "No distribution files found to upload."
exit 1
fi
- name: Create GitHub Release
run: |
gh release create ${{ needs.details.outputs.tag_name }} dist/* --title ${{ needs.details.outputs.tag_name }} --generate-notes

0 comments on commit be6debc

Please sign in to comment.