-
Notifications
You must be signed in to change notification settings - Fork 25
162 lines (153 loc) · 5.54 KB
/
build.yml
File metadata and controls
162 lines (153 loc) · 5.54 KB
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
153
154
155
156
157
158
159
160
161
162
# Author: K4YT3X <i@k4yt3x.com>
name: dvmhost-build
on:
workflow_dispatch:
inputs:
build_type:
description: "CMake Build Type"
required: true
default: "RelWithDebInfo"
type: choice
options:
- Release
- Debug
- RelWithDebInfo
- MinSizeRel
strip_symbols:
description: "Strip Symbols"
required: false
type: boolean
create_pre_release:
description: "Create Pre-Release"
required: false
type: boolean
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: write
jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
outputs:
APPNAME: ${{ steps.get_appname.outputs.APPNAME }}
DATE: ${{ steps.get_date.outputs.DATE }}
steps:
- name: Get app name
id: get_appname
run: echo APPNAME=${{ github.event.repository.name }} >> $GITHUB_OUTPUT
- name: Get date
id: get_date
run: echo DATE=$(date +'%Y-%m-%d') >> $GITHUB_OUTPUT
build:
name: Build
needs: [setup]
strategy:
matrix:
arch: ["amd64", "arm", "aarch64"]
runs-on: ubuntu-22.04
env:
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.DATE }}-${{ matrix.arch }}
DEBIAN_FRONTEND: noninteractive
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup architecture support
run: |
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture arm64
echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list
echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=armhf,arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git build-essential cmake \
g++-arm-linux-gnueabihf \
gcc-arm-linux-gnueabihf \
g++-aarch64-linux-gnu
if [[ "${{ matrix.arch }}" == 'aarch64' ]]; then
sudo apt-get install -y libasio-dev:arm64 libssl-dev:arm64 libncurses-dev:arm64
elif [[ "${{ matrix.arch }}" == 'arm' ]]; then
sudo apt-get install -y libasio-dev:armhf libssl-dev:armhf libncurses-dev:armhf
elif [[ "${{ matrix.arch }}" == 'armhf' ]]; then
sudo apt-get install -y libasio-dev:armhf libssl-dev:armhf
else
sudo apt-get install -y libasio-dev libssl-dev libncurses-dev
fi
- name: Build
run: |
build_args=''
if [[ "${{ matrix.arch }}" == 'amd64' || "${{ matrix.arch }}" == 'arm' || "${{ matrix.arch }}" == 'aarch64' ]]; then
build_args='-DENABLE_TUI_SUPPORT=1'
else
build_args='-DENABLE_TUI_SUPPORT=0'
fi
if [[ "${{ github.event_name }}" == 'push' ]]; then
build_args="$build_args -DCMAKE_BUILD_TYPE=${{ inputs.build_type }}"
if [[ "${{ inputs.strip_symbols }}" == 'true' ]]; then
build_args="$build_args -DCMAKE_C_FLAGS='-s' -DCMAKE_CXX_FLAGS='-s'"
fi
else
build_args="$build_args -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-s' -DCMAKE_CXX_FLAGS='-s'"
fi
cmake $(echo $build_args) \
-D "CROSS_COMPILE_$(echo '${{ matrix.arch }}' | tr '[:lower:]' '[:upper:]')=1" .
make -j $(nproc)
make tarball
- name: Package
run: |
mv dvmhost_*.tar.gz ${{ env.PACKAGENAME }}.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }}
path: ${{ env.PACKAGENAME }}.tar.gz
create-release:
if: ${{ github.event.inputs.create_pre_release == 'true' }}
name: Create Release
needs: [setup, build]
runs-on: ubuntu-22.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.setup.outputs.DATE }}
name: Nightly Build ${{ needs.setup.outputs.DATE }}
draft: false
prerelease: true
upload:
if: ${{ github.event.inputs.create_pre_release == 'true' }}
name: Upload
needs: [setup, build, create-release]
strategy:
matrix:
arch: ["amd64", "arm", "aarch64"]
runs-on: ubuntu-22.04
env:
PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.DATE }}-${{ matrix.arch }}
DEBIAN_FRONTEND: noninteractive
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }}
- name: Upload release asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.setup.outputs.DATE }}
files: ${{ env.PACKAGENAME }}.tar.gz
append_body: true