-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (109 loc) · 4.07 KB
/
build-and-release.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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@v4
with:
fetch-depth: 0
- 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 docs/mkdocs.yml target/mkdocs.yml
cp -r docs/overrides target/
cp -r docs/images target/docs/
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
sed -i "s#](./docs/images/#](./images/#g" 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-20.04'"
run: |
git config user.name github-actions
git config user.email [email protected]
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/[email protected]
with:
tag_name: ${{ github.ref_name }}
delete_release: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}