Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: fix publishing of PyPI package #130

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -21,30 +28,29 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine virtualenv
pip install build virtualenv

# PyPI package
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
python -m twine upload dist/*
- name: Build Python package
run: python -m build

- name: Publish Python package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# Github release
- name: Read CHANGELOG
id: changelog
run: |
# Get bullet points from last CHANGELOG entry
CHANGELOG=$(git diff -U0 HEAD^ HEAD | grep '^[+][\* ]' | sed 's/\+//')
# Support for multiline, see
# https://github.com/actions/create-release/pull/11#issuecomment-640071918
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo "Got changelog: $CHANGELOG"
echo "body=$CHANGELOG" >> $GITHUB_OUTPUT
# Support for multiline, see
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
{
echo 'body<<EOF'
echo "$CHANGELOG"
echo EOF
} >> "$GITHUB_OUTPUT"

- name: Create release on Github
id: create_release
Expand Down
Loading