CI: fix publishing Action (#51) #12
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
name: Publish | ||
on: | ||
push: | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
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: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.0' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build virtualenv | ||
# PyPI package | ||
- 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 -D katex_prerender=1 | ||
- 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/\+//') | ||
echo "Got changelog: $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: ${{ github.ref }} | ||
name: Release ${{ github.ref_name }} | ||
body: ${{ steps.changelog.outputs.body }} |