-
Notifications
You must be signed in to change notification settings - Fork 17
73 lines (71 loc) · 2.32 KB
/
deploy-n-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
name: deploy-and-publish
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
jobs:
build:
name: build and deploy docs
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: 🔗 Install dependencies with miniconda and python 3.8
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: compas_slicer
environment-file: environment.yml
python-version: 3.8
auto-activate-base: false
auto-update-conda: true
- name: 📶 Conda info
run: conda info
- name: 💎 Install
run: |
python -m pip install --no-cache-dir -r requirements-dev.txt
- name: 📃 Generate docs
if: success()
run: |
invoke docs --check-links
# Get branch/tag/latest name from git
GITHUB_REF_REGEX="tags/v([0-9a-zA-Z\.\-]+)|(pull/[0-9]+)|heads/(.+)"
if [[ $GITHUB_REF =~ $GITHUB_REF_REGEX ]]; then
if [[ $BASH_REMATCH = pull* ]]; then
BRANCH_OR_TAG=pull_${BASH_REMATCH##*/}
elif [[ $BASH_REMATCH = tags/v* ]]; then
# 2nd element is tag, #v replaces prefix v
BRANCH_OR_TAG=${BASH_REMATCH[1]#v}
else
BRANCH_OR_TAG=${BASH_REMATCH##*/}
fi;
if [[ $BRANCH_OR_TAG = master ]]; then
BRANCH_OR_TAG=latest
fi;
fi;
echo "Docs will be deployed to https://compas.dev/compas_slicer/$BRANCH_OR_TAG"
mkdir -p deploy/$BRANCH_OR_TAG && mv -T dist/docs deploy/$BRANCH_OR_TAG/
- name: 🚢 Deploy docs
if: success()
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: deploy
keep_history: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 💃 Build release
if: success() && startsWith(github.ref, 'refs/tags')
run: |
python setup.py clean --all sdist bdist_wheel
- name: 📦 Publish release to PyPI
if: success() && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}