Merge pull request #7 from rok4/develop #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, build and publish artefacts and documentation | |
on: | |
push: | |
tags: | |
- '**' | |
jobs: | |
create_release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
job_status: ${{ job.status }} | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
generateReleaseNotes: true | |
draft: false | |
prerelease: false | |
build_and_test: | |
name: Build artefacts | |
needs: create_release | |
outputs: | |
job_status: ${{ job.status }} | |
strategy: | |
max-parallel: 2 | |
fail-fast: true | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
- os: ubuntu-22.04 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Install system dependencies | |
run: | | |
sudo apt update | |
sudo apt -y install libcurl4-openssl-dev libproj-dev \ | |
libboost-log-dev libboost-filesystem-dev libboost-system-dev \ | |
jq gettext build-essential cmake doxygen graphviz | |
core_cpp_version=$(curl --silent "https://api.github.com/repos/rok4/core-cpp/releases/latest" | jq -r ".tag_name") | |
curl -L -o librok4-dev.deb https://github.com/rok4/core-cpp/releases/download/${core_cpp_version}/librok4-base-${core_cpp_version}-${{ matrix.os }}-amd64.deb | |
sudo apt install ./librok4-dev.deb | |
- name: Build packages | |
run: | | |
mkdir build && cd build | |
cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_VERSION=${{ github.ref_name }} -DCPACK_SYSTEM_NAME=${{ matrix.os }} .. | |
make -j2 | |
make package | |
- name: Upload packages to release | |
uses: AButler/[email protected] | |
with: | |
files: 'build/*.deb;build/*.tar.gz' | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
release-tag: ${{ github.ref_name }} | |
- name: Build documentation | |
if: "matrix.os == 'ubuntu-20.04'" | |
run: | | |
cd build | |
make doc | |
cd .. | |
cp -r README.md CHANGELOG.md docs/images dist/ | |
- name: Upload documentation | |
if: "matrix.os == 'ubuntu-20.04'" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-py3 | |
path: dist/ | |
if-no-files-found: error | |
retention-days: 1 | |
commit_documentation: | |
name: Add documentation into gh-pages branch | |
needs: build_and_test | |
if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build_and_test.outputs.job_status=='success')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project on gh-pages | |
uses: actions/checkout@v3 | |
with: | |
ref: 'gh-pages' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dist-py3 | |
path: artifact/ | |
- name: Copy version elements to final location | |
run: | | |
mkdir -p docs/versions/${{ github.ref_name }}/docs | |
cp -r artifact/html docs/versions/${{ github.ref_name }}/ | |
cp -r artifact/images docs/versions/${{ github.ref_name }}/docs/ | |
- name: Add pages from templates | |
run: | | |
sed "s#__version__#${{ github.ref_name }}#" templates/mkdocs.template.yml >mkdocs.yml | |
sed "s#__version__#${{ github.ref_name }}#" templates/documentation.template.md >docs/versions/${{ github.ref_name }}/documentation.md | |
sed "s#__version__#${{ github.ref_name }}#" templates/index-version.template.md >docs/versions/${{ github.ref_name }}/index.md | |
cat artifact/README.md >>docs/versions/${{ github.ref_name }}/index.md | |
sed -i "s#x.y.z#${{ github.ref_name }}#g" docs/versions/${{ github.ref_name }}/index.md | |
cp templates/index-versions.template.md docs/versions/index.md | |
sed "s/^## \(.*\)$/## \1 \n\n[➔ Lien vers la documentation](\1\/index.md) /" artifact/CHANGELOG.md >>docs/versions/index.md | |
sed "s#__version__#${{ github.ref_name }}#" templates/latest.template.html >docs/versions/latest/index.html | |
rm -r artifact | |
- name: Publish on gh-pages branch | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add -v docs/versions/${{ github.ref_name }}/ docs/versions/latest/ docs/index.md docs/versions/index.md | |
git commit -m "Add documentation for version ${{ github.ref_name }}" | |
git push | |
delete_version: | |
name: Remove release and tag if error occured | |
needs: build_and_test | |
if: "always()&&(needs.create_release.outputs.job_status=='success')&&(needs.build_and_test.outputs.job_status!='success')" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Remove release and tag | |
uses: dev-drprasad/[email protected] | |
with: | |
tag_name: ${{ github.ref_name }} | |
delete_release: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |