-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e436c6
commit 503435f
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,7 @@ on: | |
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
|
@@ -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/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters