Maintenance: Update GitHub actions #321
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] | |
jobs: | |
Publish: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.8 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached Poetry virtualenv | |
uses: actions/cache@v4 | |
id: cached-poetry-dependencies | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Build | |
run: poetry build | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Create example tarball | |
run: tar cvzf examples.tar.gz examples/ | |
# What we do here is print everything before the second occurent of the | |
# word Version. This is going to be the release message. | |
- name: Create changelog entry | |
run: | | |
awk -v N=2 '{print}/Version/&&--N<=0{exit}' NEWS.md | head -n -2 | tail -n +3 > ${{ github.workflow }}-CHANGELOG.txt | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: examples.tar.gz | |
body_path: ${{ github.workflow }}-CHANGELOG.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Dependencies | |
run: | | |
poetry install -E full | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
- name: Produce documentation | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pandoc | |
sudo apt-get install -y xvfb | |
cd docs/ | |
xvfb-run poetry run make html | |
cd .. | |
- name: Commit documentation changes | |
run: | | |
git clone https://github.com/sbozzolo/kuibit.git --branch gh-pages --single-branch gh-pages | |
mkdir -p gh-pages/"$(poetry version -s)" | |
cp -r docs/_build/html/* gh-pages/"$(poetry version -s)" | |
cd gh-pages | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m "Update documentation" -a || true | |
# The above command will fail if no changes were present, so we ignore | |
# the return code. | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
branch: gh-pages | |
# force: true | |
directory: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} |