-
Notifications
You must be signed in to change notification settings - Fork 373
104 lines (93 loc) · 3.73 KB
/
publish-docs.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
name: Publish docs via GitHub Pages
on:
push:
branches:
- main
release:
types:
- published
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout k0s
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare build environment
run: .github/workflows/prepare-build-env.sh
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: docs/requirements.txt
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: |
pip install --disable-pip-version-check -r docs/requirements_pip.txt
pip --version
pip install --disable-pip-version-check -r docs/requirements.txt
go install github.com/k0sproject/version/cmd/[email protected]
- name: Generate docs
env:
GH_TOKEN: ${{ github.token }}
run: make -C docs docs clean-k0s
- name: git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
# This deploys the current docs into gh-pages/head on merges to main
# The old "main" gets deleted if it exists, head is more descriptive
- name: mike deploy head
if: contains(github.ref, 'refs/heads/main')
run: |
KUBE_VERSION="$(./vars.sh kubernetes_version)" mike deploy --push head
# If a release has been published, deploy it as a new version
- name: mike deploy new version
if: >-
github.event_name == 'release' &&
github.event.action == 'published' &&
!github.event.release.draft &&
!github.event.release.prerelease
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
KUBE_VERSION="$(./vars.sh kubernetes_version)" mike deploy --push "$VERSION"
- name: Update mike version aliases
if: github.repository == 'k0sproject/k0s'
id: set_versions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAGS=$(gh release list -L 1000 -R "$GITHUB_REPOSITORY" | grep "+k0s." | grep -v Draft | cut -f 1 | k0s_sort)
LATEST=$(echo "${TAGS}" | tail -1)
STABLE=$(echo "${TAGS}" | grep -v -- "-" | tail -1)
mike alias -u head main
mike alias -u "${STABLE}" stable
mike set-default --push stable
echo LATEST="$LATEST" >> $GITHUB_OUTPUT
echo STABLE="$STABLE" >> $GITHUB_OUTPUT
# Ensures the current branch is gh-pages,
# Creates / updates the "stable" and "latest" plain text files with the corresponding versions
# Commits if the files were changed
# Finally pushes if there are unpushed commits
- name: Create version files
if: github.repository == 'k0sproject/k0s'
run: |
LATEST=${{ steps.set_versions.outputs.LATEST }}
STABLE=${{ steps.set_versions.outputs.STABLE }}
cp .github/workflows/channel.yaml.tpl /tmp/tpl
git checkout gh-pages
echo "${STABLE}" > stable.txt
git add stable.txt && git update-index --refresh
git diff-index --quiet HEAD -- || git commit -m "Set stable to ${STABLE}"
echo "${LATEST}" > latest.txt
cat /tmp/tpl | sed "s/{{ .Version }}/${LATEST}/g" > edge_release
git add latest.txt edge_release && git update-index --refresh
git diff-index --quiet HEAD -- || git commit -m "Set latest to ${LATEST}"
git push origin gh-pages