-
Notifications
You must be signed in to change notification settings - Fork 4
118 lines (111 loc) · 3.16 KB
/
release.yaml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Release
on:
push:
tags:
- v*
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: |
# Assert git and python versions match
pip install -e .
pip install -r examples/requirements.txt
VERSION_PY=$(python3 -c "from xplt import __version__;print('v' + __version__)")
echo "Python version: $VERSION_PY"
VERSION_GIT=$(git describe --tags)
echo "Git version tag: $VERSION_GIT"
if [ "$VERSION_GIT" != "$VERSION_PY" ] ; then
echo "Version mismatch!"
exit 1
fi
pypi-test:
needs: checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: |
pip install build
- name: Build
run: |
python -m build
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
ready:
needs: [checks, pypi-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
VERSION=$(git describe --tags)
echo "Version: $VERSION"
if [[ $VERSION =~ v[0-9]+(\.[0-9]+)*$ ]] ; then
echo "Ready for publication"
else
echo "Not publishing dirty versions"
exit 1
fi
docs-publish:
needs: ready
runs-on: ubuntu-latest
env:
PAGES_BRANCH: gh-pages
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -e .
pip install -r docs/requirements.txt
- name: Sphinx build
run: |
sphinx-build docs _build/html
VERSION=$(python -c "from docs.conf import version;print('.'.join(version.split('.')[:2]))")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Deploy docs
run: |
git config user.name "GitHub Actions"
git config user.email "<>"
git checkout $PAGES_BRANCH
# Copy to version folder
rm -rf $VERSION
cp -r _build/html $VERSION
# Update docs
./update.py
cat versions.json
# Commit and push
git add $VERSION latest versions.json
git commit -m "Deploy docs/$VERSION"
git push origin $PAGES_BRANCH
pypi-publish:
needs: ready
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: |
pip install build
- name: Build
run: |
python -m build
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}