Skip to content

Test, build and publish artefacts and documentation #25

Test, build and publish artefacts and documentation

Test, build and publish artefacts and documentation #25

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: Update changelog
# uses: thomaseizinger/keep-a-changelog-new-release@v2
# with:
# tag: ${{ github.ref_name }}
# - name: Commit changelog
# uses: devops-infra/action-commit-push@v1.1.0
# with:
# github_token: "${{ secrets.GITHUB_TOKEN }}"
# commit_message: "Versionnement du changelog"
# target_branch: master
- name: Get latest release info
id: query_release_info
uses: release-flow/keep-a-changelog-action@v2
with:
command: query
version: latest
- name: Write release notes
run: |
echo "{{ query_release_info.outputs.release-notes }}" >notes.txt
- 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 }}
bodyFile: notes.txt
draft: false
prerelease: false
build_and_test:
name: Test and build artefacts
needs: create_release
outputs:
job_status: ${{ job.status }}
strategy:
max-parallel: 2
fail-fast: true
matrix:
include:
- os: ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
sudo apt update
sudo apt -y install zlib1g-dev libcurl4-openssl-dev libproj-dev libssl-dev libturbojpeg0-dev \
libjpeg-dev libc6-dev libboost-log-dev libboost-filesystem-dev libboost-system-dev \
libsqlite3-dev libpng-dev libtiff5-dev libopenjp2-7-dev librados-dev \
gettext build-essential cmake libcppunit-dev doxygen graphviz
- 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
cmake -DCEPH_ENABLED=1 ..
make -j2
make package
- name: Run unit tests
if: "matrix.os == 'ubuntu-22.04'"
run: |
cd build
make test
- name: Upload packages to release
uses: AButler/upload-release-assets@v2.0
with:
files: 'build/*.deb;build/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ github.ref_name }}
- name: Build documentation
if: "matrix.os == 'ubuntu-22.04'"
run: |
cd build
make doc
cd ..
cp docs/mkdocs.yml target/mkdocs.yml
cp -r docs/overrides target/
cp docs/documentation.md target/docs/documentation.md
cp docs/README.hdr.md target/docs/README.md
cp docs/CHANGELOG.hdr.md target/docs/CHANGELOG.md
cp docs/CONTRIBUTING.hdr.md target/docs/CONTRIBUTING.md
sed "s#x.y.z#${{ github.ref_name }}#g" README.md >>target/docs/README.md
cat CHANGELOG.md >>target/docs/CHANGELOG.md
cat CONTRIBUTING.md >>target/docs/CONTRIBUTING.md
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: Install Mkdocs
run: pip install -r docs/requirements.txt
- name: Publish documentation
if: "matrix.os == 'ubuntu-22.04'"
run: |
git config user.name github-actions
git config user.email github-actions@github.com
cd target/
mike deploy --push --update-aliases --branch gh-pages -t "Version ${{ github.ref_name }}" ${{ github.ref_name }} latest
mike set-default --push --branch gh-pages ${{ github.ref_name }}
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/delete-tag-and-release@v0.2.0
with:
tag_name: ${{ github.ref_name }}
delete_release: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}