@@ -3,7 +3,8 @@ name: Test, build and publish artefacts and documentation
33on :
44 push :
55 tags :
6- - ' **'
6+ - ' [0-9]+.[0-9]+.[0-9]+'
7+ - ' [0-9]+.[0-9]+.[0-9]+b[0-9]+'
78
89jobs :
910
@@ -19,15 +20,14 @@ jobs:
1920
2021 - name : Create Release
2122 id : create_release
22- uses : actions/create-release@v1
23- env :
24- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23+ uses : ncipollo/release-action@v1
2524 with :
26- tag_name : ${{ github.ref_name }}
27- release_name : Release ${{ github.ref_name }}
28- body_path : CHANGELOG.md
25+ token : ${{ secrets.GITHUB_TOKEN }}
26+ tag : ${{ github.ref_name }}
27+ name : Release ${{ github.ref_name }}
28+ generateReleaseNotes : true
2929 draft : false
30- prerelease : false
30+ prerelease : ${{ contains(github.ref_name ,'b') }}
3131
3232 build_and_test :
3333
@@ -68,41 +68,40 @@ jobs:
6868 python3 -m venv .venv
6969 source .venv/bin/activate
7070 python3 -m pip install --upgrade build bump2version
71- bump2version --current-version 0.0.0 --new-version ${{ github.ref_name }} patch pyproject.toml src/rok4/__init__.py
71+ bump2version --current-version 0.0.0 --new-version ${{ github.ref_name }} patch
7272 pip install -e .
7373 echo "/usr/lib/python3/dist-packages/" >.venv/lib/python${{ matrix.python-version }}/site-packages/system.pth
7474
7575 - name : Run unit tests
76- if : " (${{ matrix.os }}=='ubuntu-20.04')&&(${{ matrix.python-version }}=='3.8')"
7776 run : |
7877 source .venv/bin/activate
7978 pip install -e .[test]
8079 coverage run -m pytest
8180 coverage report -m
8281
8382 - name : Build unit tests report
84- if : " (${{ matrix.os }}== 'ubuntu-20.04')&&(${{ matrix.python-version }}== '3.8') "
83+ if : " ! contains(github.ref_name,'b') && matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8'"
8584 run : |
8685 source .venv/bin/activate
8786 coverage html -d dist/tests/
8887 rm dist/tests/.gitignore
8988
9089 - name : Build package
91- if : " (${{ matrix.os }}== 'ubuntu-20.04')&&(${{ matrix.python-version }}== '3.8') "
90+ if : " matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8'"
9291 run : |
9392 source .venv/bin/activate
9493 python3 -m build
9594
9695 - name : Build documentation
97- if : " (${{ matrix.os }}== 'ubuntu-20.04')&&(${{ matrix.python-version }}== '3.8') "
96+ if : " ! contains(github.ref_name,'b') && matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8'"
9897 run : |
9998 source .venv/bin/activate
10099 pip install -e .[doc]
101100 pdoc3 --html --output-dir dist/ rok4
102101 cp README.md CHANGELOG.md dist/
103102
104103 - name : Upload packages, tests results and documentation
105- if : " (${{ matrix.os }}== 'ubuntu-20.04')&&(${{ matrix.python-version }}== '3.8') "
104+ if : " matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.8'"
106105 uses : actions/upload-artifact@v3
107106 with :
108107 name : dist-py3
@@ -113,7 +112,7 @@ jobs:
113112 publish_artefacts :
114113 name : Add built artefacts to release and PyPI
115114 needs : [create_release, build_and_test]
116- if : " always()&&( needs.create_release.outputs.job_status== 'success')&&( needs.build_and_test.outputs.job_status== 'success') "
115+ if : " always() && needs.create_release.outputs.job_status == 'success' && needs.build_and_test.outputs.job_status == 'success'"
117116 runs-on : ubuntu-latest
118117
119118 steps :
@@ -135,7 +134,7 @@ jobs:
135134 asset_content_type : application/zip
136135
137136 - name : Add tarball package to release
138- id : upload-release-targz
137+ id : upload-release-targz
139138 uses : actions/upload-release-asset@v1
140139 env :
141140 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -159,7 +158,7 @@ jobs:
159158 commit_documentation :
160159 name : Add documentation and unit tests results into gh-pages branch
161160 needs : build_and_test
162- if : " always()&&( needs.create_release.outputs.job_status== 'success')&&( needs.build_and_test.outputs.job_status== 'success') "
161+ if : " always() && ! contains(github.ref_name,'b') && needs.create_release.outputs.job_status == 'success' && needs.build_and_test.outputs.job_status == 'success'"
163162 runs-on : ubuntu-latest
164163
165164 steps :
@@ -183,31 +182,33 @@ jobs:
183182
184183 - name : Add pages from templates
185184 run : |
186- sed "s#__version__#${{ github.ref_name }}#" templates/TESTS.template.md >docs/versions/${{ github.ref_name }}/TESTS.md
187- sed "s#__version__#${{ github.ref_name }}#" templates/DOCUMENTATION.template.md >docs/versions/${{ github.ref_name }}/DOCUMENTATION.md
188- sed "s#__version__#${{ github.ref_name }}#" templates/CHANGELOG.template.md >docs/versions/${{ github.ref_name }}/CHANGELOG.md
189- cat artifact/CHANGELOG.md >>docs/versions/${{ github.ref_name }}/CHANGELOG.md
190- sed "s#__version__#${{ github.ref_name }}#" templates/README.template.md >docs/versions/${{ github.ref_name }}/README.md
191- cat artifact/README.md >>docs/versions/${{ github.ref_name }}/README.md
192- sed "s#__version__#${{ github.ref_name }}#" templates/index.template.md >docs/index.md
193- echo "# Versions" >docs/versions.md
194- echo "" >>docs/versions.md
195- for v in `ls -t docs/versions | grep -v latest`; do sed "s#__version__#$v#" templates/versions.template.md >>docs/versions.md; done
185+ sed "s#__version__#${{ github.ref_name }}#" templates/mkdocs.template.yml >mkdocs.yml
186+
187+ sed "s#__version__#${{ github.ref_name }}#" templates/unit-tests.template.md >docs/versions/${{ github.ref_name }}/unit-tests.md
188+ sed "s#__version__#${{ github.ref_name }}#" templates/documentation.template.md >docs/versions/${{ github.ref_name }}/documentation.md
189+
190+ sed "s#__version__#${{ github.ref_name }}#" templates/index-version.template.md >docs/versions/${{ github.ref_name }}/index.md
191+ cat artifact/README.md >>docs/versions/${{ github.ref_name }}/index.md
192+ sed -i "s#x.y.z#${{ github.ref_name }}#g" docs/versions/${{ github.ref_name }}/index.md
193+
194+ cp templates/index-versions.template.md docs/versions/index.md
195+ sed "s/^## \(.*\)$/## \1 \n\n[➔ Lien vers la documentation](\1\/index.md) /" artifact/CHANGELOG.md >>docs/versions/index.md
196+
196197 sed "s#__version__#${{ github.ref_name }}#" templates/latest.template.html >docs/versions/latest/index.html
197198 rm -r artifact
198199
199200 - name : Publish on gh-pages branch
200201 run : |
201202 git config user.name github-actions
202203 git config user.email github-actions@github.com
203- git add -v docs/versions/${{ github.ref_name }}/ docs/versions/latest/ docs/index.md docs/versions.md
204+ git add -v docs/versions/${{ github.ref_name }}/ docs/versions/latest/ docs/versions/ index.md mkdocs.yml
204205 git commit -m "Add documentation for version ${{ github.ref_name }}"
205206 git push
206207
207208 delete_version :
208209 name : Remove release and tag if error occured
209210 needs : build_and_test
210- if : " always()&&( needs.create_release.outputs.job_status== 'success')&&( needs.build_and_test.outputs.job_status!= 'success') "
211+ if : " always() && needs.create_release.outputs.job_status == 'success' && needs.build_and_test.outputs.job_status != 'success'"
211212 runs-on : ubuntu-latest
212213
213214 steps :
@@ -218,4 +219,3 @@ jobs:
218219 delete_release : true
219220 env :
220221 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
221-
0 commit comments