-
Notifications
You must be signed in to change notification settings - Fork 11
129 lines (125 loc) · 4.37 KB
/
ci-prod.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
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
118
119
120
121
122
123
124
125
126
127
128
129
name: "Build & publish - PROD"
on:
release:
types: [released]
jobs:
run-tests:
name: "Run tests job"
uses: ./.github/workflows/_tests.yml
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: pdm-project/setup-pdm@v3
name: Setup PDM
with:
python-version: 3.11
architecture: x64
enable-pep582: true
cache: true
cache-dependency-path: "**/pdm.lock"
- name: Publish distribution 📦 to PyPI
run: pdm publish --repository pypi --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} --verbose
generate-docs:
name: Generate latest library 📚 documentation 📄
needs: [run-tests]
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
env:
MKDOCS_EXECUTE_JUPYTER: false # execution is done before rendering documentation
MKDOCS_DEV: false
FORCE_TERMINAL_MODE: true
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-prod-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-pip-prod-
- name: Install pdm
run: pip install pdm
- name: Generate requirements.txt
run: pdm export --no-default -G docs -G visualization -G cli-dev -f requirements -o requirements.txt
- name: Install dependencies
run: pip install --no-deps -r requirements.txt
- name: Install quackosm
run: |
pdm build -v -d dist
pip install 'quackosm[cli] @ file://'"$(pwd)/$(find dist -name '*.whl')" --user
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Cache OSM data
uses: actions/cache@v3
with:
path: "**/cache"
key: mkdocs-osm-dev-cache-${{ runner.os }}
- name: Prepare DuckDB dependency
run: |
wget https://github.com/duckdb/duckdb/releases/download/v0.9.2/duckdb_cli-linux-amd64.zip
unzip duckdb_cli-linux-amd64.zip
chmod a+x ./duckdb
- name: Test required commands
run: |
./duckdb :memory: "SELECT 1"
QuackOSM -h
- name: Execute jupyter notebooks
run: |
mv ./duckdb ./examples/duckdb
jupyter nbconvert --to notebook --inplace --execute $(find examples/ -type f -name "*.ipynb") --ExecutePreprocessor.kernel_name='python3'
rm ./examples/duckdb
- uses: jannekem/run-python-script-action@v1
name: Replace copyright date
with:
script: |
import time
file_name = "mkdocs.yml"
with open(file_name) as f:
data = f.read().replace('{current_year}', time.strftime("%Y"))
with open(file_name, "w") as f:
f.write(data)
- name: Create remote for quackosm-docs repository
run: git remote add origin-quackosm-docs https://github.com/kraina-ai/quackosm-docs
- name: Fetch gh-pages branch
run: git fetch origin-quackosm-docs gh-pages --depth=1
- name: Publish latest documentation
run: mike deploy --remote origin-quackosm-docs --rebase --push --update-aliases ${{github.ref_name}} latest
deploy-docs:
name: Deploy documentation 📄 to Github Pages 🌐
needs: [generate-docs]
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
repository: 'kraina-ai/quackosm-docs'
ref: 'gh-pages'
token: ${{ secrets.CICD_PAT_TOKEN }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2