-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (113 loc) · 3.7 KB
/
docset.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
name: Check latest Optuna release and build docset
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs:
debug:
description: "Debug flag (if true, no commits are pushed)"
required: false
type: boolean
default: true
jobs:
fetch:
name: Check latest Optuna release and build docset
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.latest.outputs.version }}
current: ${{ steps.current.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: get the latest optuna release tag
id: latest
run: |
version=$(curl -s "${GITHUB_API_URL}/repos/optuna/optuna/releases/latest" | jq -r '.["tag_name"]')
echo "version=${version}" >> $GITHUB_OUTPUT
echo latest verion: $version
- name: get current .version
id: current
run: |
version=$(cat .version)
echo "version=${version}" >> $GITHUB_OUTPUT
echo current verion: $version
build:
runs-on: ubuntu-latest
needs: fetch
name: Build document
if: ${{ needs.fetch.outputs.latest != needs.fetch.outputs.current || github.event.inputs.debug == 'true' }}
outputs:
latest: ${{ needs.fetch.outputs.latest }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: checkout the latest release
run: |
git clone --depth 1 --branch ${{ needs.fetch.outputs.latest }} https://github.com/optuna/optuna.git
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: install dependencies
run: |
cd optuna
sudo apt-get install optipng
python -m pip install -U pip
pip install --progress-bar off -U .[document]
- name: Build Document
run: |
cd optuna/docs
make html
- uses: actions/upload-artifact@v3
with:
name: built-html
path: optuna/docs/build/html
docset:
runs-on: ubuntu-latest
needs: build
name: Convert to docset
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/download-artifact@v3
with:
name: built-html
path: optuna/docs/build/html
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: install doc2dash
run: |
python -m pip install -U pip
pip install doc2dash
- name: convert HTML to docset
run: |
doc2dash \
--name Optuna \
--destination . \
--force \
--index-page index.html \
--online-redirect-url https://optuna.readthedocs.io \
./optuna/docs/build/html
cp ./icon/*.png Optuna.docset/
- uses: actions/upload-artifact@v3
with:
name: Optuna.docset
path: ./Optuna.docset
- name: push docset
# memo: `debug` will be empty when workflow triggered by schedule.
if: ${{ github.event.inputs.debug != 'true' }}
run: |
git config --global user.email "${{ secrets.CI_USER_EMAIL }}"
git config --global user.name "${{ secrets.CI_USER_USERNAME }}"
printf "${{ needs.build.outputs.latest }}\n" > .version
git add .version
git add Optuna.docset
git commit -m "optuna/optuna@${{ needs.build.outputs.latest }}"
git tag ${{ needs.build.outputs.latest }}
git push \
"https://${{ secrets.CI_USER_USERNAME }}:${{ secrets.CI_USER_ACCESS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" \
HEAD:main \
--tags