1818 steps :
1919 - name : Fetch sources
2020 uses : actions/checkout@v3
21- with :
22- submodules : true
2321
2422 - name : Set up Python
2523 uses : actions/setup-python@v4
4745 steps :
4846 - name : Fetch sources
4947 uses : actions/checkout@v3
50- with :
51- submodules : true
5248
5349 - name : Set up Python
5450 uses : actions/setup-python@v4
@@ -70,8 +66,116 @@ jobs:
7066 path : dist/
7167 if-no-files-found : error
7268
73- create-github-release :
69+ generate-docs-pr :
70+ if : github.event_name == 'pull_request'
71+ runs-on : ubuntu-20.04
72+ steps :
73+ - name : Fetch sources
74+ uses : actions/checkout@v3
75+
76+ - name : Setup Git user and e-mail
77+ uses : frequenz-floss/setup-git-user@v1
78+
79+ - name : Set up Python
80+ uses : actions/setup-python@v4
81+ with :
82+ python-version : " 3.10"
83+
84+ - name : Install build dependencies
85+ run : |
86+ python -m pip install -U pip
87+ python -m pip install .[docs]
88+
89+ - name : Generate the documentation
90+ env :
91+ MIKE_VERSION : pr-${{ github.event.number }}
92+ run : |
93+ mike deploy $MIKE_VERSION
94+ mike set-default $MIKE_VERSION
95+
96+ - name : Upload site
97+ uses : actions/upload-artifact@v3
98+ with :
99+ name : frequenz-channels-python-site
100+ path : site/
101+ if-no-files-found : error
102+
103+ publish-docs :
74104 needs : ["test", "build-dist"]
105+ if : github.event_name == 'push'
106+ runs-on : ubuntu-20.04
107+ steps :
108+ - name : Calculate and check version
109+ id : mike-metadata
110+ env :
111+ REF : ${{ github.ref }}
112+ REF_NAME : ${{ github.ref_name }}
113+ DEFAULT_BRANCH : ${{ github.event.repository.default_branch }}
114+ run : |
115+ aliases=
116+ version=
117+ if test "$REF_NAME" = "$DEFAULT_BRANCH"
118+ then
119+ version=next
120+ # A tag that starts with vX.Y or X.Y
121+ elif echo "$REF" | grep -q '^refs/tags' && echo "$REF_NAME" | grep -Pq '^v?\d+\.\d+\.'
122+ then
123+ if echo "$REF_NAME" | grep -Pq -- "-" # pre-release
124+ then
125+ echo "::notice title=Documentation was not published::" \
126+ "The tag '$REF_NAME' looks like a pre-release."
127+ exit 0
128+ fi
129+ version=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+\.[0-9]+)\..*$/\1/') # vX.Y
130+ major=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
131+ default_major=$(echo "$DEFAULT_BRANCH" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
132+ aliases=$major
133+ if test "$major" = "$default_major"
134+ then
135+ aliases="$aliases latest"
136+ fi
137+ else
138+ echo "::warning title=Documentation was not published::" \
139+ "Don't know how to handle '$REF' to make 'mike' version."
140+ exit 0
141+ fi
142+ echo "version=$version" >> $GITHUB_OUTPUT
143+ echo "aliases=$aliases" >> $GITHUB_OUTPUT
144+
145+ - name : Fetch sources
146+ if : steps.mike-metadata.outputs.version
147+ uses : actions/checkout@v3
148+
149+ - name : Setup Git user and e-mail
150+ if : steps.mike-metadata.outputs.version
151+ uses : frequenz-floss/setup-git-user@v1
152+
153+ - name : Set up Python
154+ if : steps.mike-metadata.outputs.version
155+ uses : actions/setup-python@v4
156+ with :
157+ python-version : " 3.10"
158+
159+ - name : Install build dependencies
160+ if : steps.mike-metadata.outputs.version
161+ run : |
162+ python -m pip install -U pip
163+ python -m pip install .[docs]
164+
165+ - name : Fetch the gh-pages branch
166+ if : steps.mike-metadata.outputs.version
167+ run : git fetch origin gh-pages --depth=1
168+
169+ - name : Publish site
170+ if : steps.mike-metadata.outputs.version
171+ env :
172+ VERSION : ${{ steps.mike-metadata.outputs.version }}
173+ ALIASES : ${{ steps.mike-metadata.outputs.aliases }}
174+ run : |
175+ mike deploy --push "$VERSION" $ALIASES
176+
177+ create-github-release :
178+ needs : ["publish-docs"]
75179 # Create a release only on tags creation
76180 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
77181 permissions :
0 commit comments