Skip to content

Commit

Permalink
CI: fix creating release (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Nov 30, 2023
1 parent 2027bce commit 7fbd034
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,72 @@ 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@v3
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel build
# PyPI package
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m twine upload dist/*
# Docuemntation
- name: Build Python package
run: python -m build

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

# Documentation
- name: Install doc dependencies
run: |
pip install -r requirements.txt
pip install -r docs/requirements.txt
- name: Build documentation
run: |
python -m sphinx docs/ docs/_build/ -b html
- name: Deploy documentation to Github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build

# 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 "::set-output name=body::$CHANGELOG"
# 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
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
name: Release ${{ steps.get_version.outputs.version }}
tag_name: ${{ github.ref }}
name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.body }}

0 comments on commit 7fbd034

Please sign in to comment.