-
Notifications
You must be signed in to change notification settings - Fork 11
92 lines (76 loc) · 2.69 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Publish
on: [push]
jobs:
Publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python 3.8
uses: actions/setup-python@v4
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@v3
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 }}