-
Notifications
You must be signed in to change notification settings - Fork 56
131 lines (101 loc) · 4.47 KB
/
release-docs.yml
File metadata and controls
131 lines (101 loc) · 4.47 KB
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
130
131
name: Release docs pipeline
on:
# Run when release is published
release:
types: [published]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
pull-requests: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build-and-publish:
name: Create a new docs release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set release tag
run: |
R=${GITHUB_REF#"refs/tags/"}
echo "RELEASE=$R" >> $GITHUB_ENV
- name: Set up git author
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Handle Changelog file
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
filename="mkdocs.yml"
start_line=$(sed -n '/- Changelog:/=' "$filename")
changelogs_from_dir=$(ls ./docs/CHANGELOG)
changelogs_from_mkdocs_file=$(grep -Eo "CHANGELOG/changelog-[0-9]+\.[0-9]+\.x\.md" "$filename" | awk -F'/' '{print $2}')
changelogs_mkdocs_arr=( $changelogs_from_mkdocs_file )
changelogs_dir_arr=( $changelogs_from_dir )
new_changelog_file=""
# check if all files from CHANGELOG dir are present in mkdocs.yml
for value in "${changelogs_dir_arr[@]}"; do
if [[ ! " ${changelogs_mkdocs_arr[@]} " =~ " $value " ]]; then
# the value of the new_changelog_file will be name of the changelog file, which isn't in mkdocs.yml nav
new_changelog_file=$value
fi
done
# add new navigation entry only, when there is a new changelog file
if [[ -n "$new_changelog_file" ]]; then
echo "Found new changelog file"
version=$(echo $new_changelog_file | grep -oE [0-9]+\.[0-9]+)
navigation_entry="Claudie v$version: CHANGELOG/$new_changelog_file"
new_entry_line=$(($start_line + ${#changelogs_dir_arr[@]}))
sed -i "${new_entry_line}i\\
- ${navigation_entry}" $filename
git fetch
git checkout -b feat/add-reference-to-new-changelog-${RELEASE}
# commit and push
git commit -am "add new changelog file to mkdocs.yml"
git push --set-upstream origin feat/add-reference-to-new-changelog-${RELEASE}
echo "Altered mkdocs.yml with new Changelog navigation entry was commited and pushed to origin"
gh pr create --title "Add reference to new Changelog ${RELEASE}" --body "Add reference to new Changelog file in mkdocs.yml"
else
echo "There isn't a new changelog file"
fi
# NOTE: the pipeline will fail, if gh-pages branch isn't created!!!
- name: Git fetch gh-pages
run: git fetch origin gh-pages
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install Python dependencies
run: pip install -r requirements.txt
# this is only possible, when there is already a version with latest alias
# in case there isn't a version like this you have to
# 1. mike deploy <version> latest
# 2. mike set-default latest
# 3. mike deploy <version_from_cmd_1> latest --push
# --push flag in the latest cmd is necessary, when you want to apply changes in gh-pages branch and also in GH Pages
- name: Deploy new docs version
run: mike deploy ${RELEASE} latest --update-aliases --push
# The llms files need to be located in the root path of a website
- name: Copy llms files to root of gh-pages
run: |
set -e
git checkout gh-pages
cp latest/{llms-full.txt,llms.txt} .
git add llms-full.txt llms.txt
if git commit -m "Add llms files to root"; then
echo "Committed llms files to root"
git push origin gh-pages
else
echo "No changes to commit for llms files"
fi
git checkout -