-
Notifications
You must be signed in to change notification settings - Fork 19
152 lines (128 loc) · 4.83 KB
/
build.yml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Build Illarion Server Image
on:
push:
branches:
tags:
pull_request:
schedule:
- cron: '00 15 * * 5'
workflow_dispatch:
jobs:
build:
name: Compile and Test
runs-on: ubuntu-latest
strategy:
matrix:
build-type: [Release, RelWithDebInfo]
container:
image: debian:bullseye
steps:
- name: Install dependencies
run: |
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -qq install build-essential git wget file
apt-get -y -qq install libboost-graph-dev libboost-system-dev libpq-dev lua5.2-dev
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O cmake.sh -q
sh cmake.sh --skip-license --prefix=/usr/local
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Create Build Environment
id: cmake-setup
shell: bash
run: |
cmake -E make_directory ../build
cd ../build
echo "build-directory=$(pwd -P)" >> $GITHUB_OUTPUT
- name: Initialize CodeQL
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/init@v1
with:
languages: cpp
- name: Configure CMake
shell: bash
working-directory: ${{ steps.cmake-setup.outputs.build-directory }}
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
- name: Build
working-directory: ${{ steps.cmake-setup.outputs.build-directory }}
shell: bash
run: cmake --build . --config ${{ matrix.build-type }} --parallel 2
- name: Perform CodeQL Analysis
if: ${{ github.event_name == 'schedule' }}
uses: github/codeql-action/analyze@v1
- name: Test
working-directory: ${{ steps.cmake-setup.outputs.build-directory }}
shell: bash
run: ctest -C ${{ matrix.build-type }}
- name: Package
working-directory: ${{ steps.cmake-setup.outputs.build-directory }}
shell: bash
run: cpack . -C ${{ matrix.build-type }}
- uses: actions/upload-artifact@v4
with:
name: Package-${{ matrix.build-type }}
path: ${{runner.workspace}}/build/*.deb
if-no-files-found: error
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'schedule' }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- name: Repo metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: Fetch Artifact
uses: actions/download-artifact@v4
with:
name: Package-RelWithDebInfo
path: ${{runner.workspace}}
- name: Prepare Docker environment
shell: bash
run: mv ${{runner.workspace}}/*.deb $GITHUB_WORKSPACE/setup/docker/base/
- uses: Illarion-eV/Illarion-Docker-Version@v2
id: docker-vars
with:
image-name: ghcr.io/${{ github.repository }}/base
registry-secret: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub
if: ${{ steps.docker-vars.outputs.has-docker-secret == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ steps.docker-vars.outputs.docker-secret }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: setup/docker/base
file: setup/docker/base/Dockerfile
platforms: linux/amd64
push: ${{ steps.docker-vars.outputs.has-docker-secret == 'true' }}
tags: ${{ steps.docker-vars.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
org.opencontainers.image.version=${{ steps.docker-vars.outputs.version }}
org.opencontainers.image.created=${{ steps.docker-vars.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
- name: Clean Docker environment
shell: bash
run: |
rm $GITHUB_WORKSPACE/setup/docker/base/*.deb