Skip to content

Commit

Permalink
Prepare for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Jan 9, 2025
1 parent 7e436c6 commit 503435f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
61 changes: 59 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ on:
branches: [ "main" ]

jobs:
build:

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -40,3 +39,61 @@ jobs:
- name: Test with pytest
run: |
pytest
deploy:
name: upload release to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/aliftools
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
# setuptools_scm requires the git clone to not be 'shallow'
fetch-depth: 0

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

- name: Extract release notes from annotated tag message
id: release_notes
env:
# e.g. v0.1.0a1, v1.2.0b2 or v2.3.0rc3, but not v1.0.0
PRERELEASE_TAG_PATTERN: "v[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+([ab]|rc)[[:digit:]]+"
run: |
# GH checkout action doesn't preserve tag annotations, we must fetch them
# https://github.com/actions/checkout/issues/290
git fetch --tags --force
# Dump tag message body to temporary .md file
echo "$(git tag -l --format='%(contents:body)' ${{ github.ref_name }})" > "${{ runner.temp }}/release_body.md"
# Set RELEASE_NAME env var to tag message subject
echo "RELEASE_NAME=$(git tag -l --format='%(contents:subject)' ${{ github.ref_name }})" >> $GITHUB_ENV
# if the tag has a pre-release suffix mark the Github Release accordingly
if egrep -q "$PRERELEASE_TAG_PATTERN" <<< "${{ github.ref_name }}"; then
echo "Tag contains a pre-release suffix"
echo "IS_PRERELEASE=true" >> "$GITHUB_ENV"
else
echo "Tag does not contain pre-release suffix"
echo "IS_PRERELEASE=false" >> "$GITHUB_ENV"
fi
- name: Create GitHub release
id: create_release
uses: softprops/action-gh-release@v2
with:
body_path: "${{ runner.temp }}/release_body.md"
draft: false
prerelease: ${{ env.IS_PRERELEASE }}

- name: Build
run: pipx run build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.12.3
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ make-sample = "alifTools.sample:main"
[tool.setuptools_scm]
version_file = "Lib/alifTools/_version.py"

[tool.distutils.bdist_wheel]
universal = true

[tool.black]
exclude = '''
(
Expand Down

0 comments on commit 503435f

Please sign in to comment.