-
Notifications
You must be signed in to change notification settings - Fork 71
217 lines (211 loc) · 7.63 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Build
on:
push:
pull_request:
types: [opened, synchronize, reopened]
release:
types: [published]
jobs:
tarball:
name: Create tarball with distcheck
runs-on: ubuntu-latest
steps:
- name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt install -y git tar gcc g++ make autoconf gettext
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Add safe git directory
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Autogen
run: ./autogen.sh
- name: Distcheck
run: make distcheck
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tarball
path: |
*.xz
build-test-linux:
name: Build Test Linux
runs-on: ubuntu-latest
steps:
- name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt install -y git tar gcc g++ make cmake
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Add safe git directory
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE="Debug" -DBUILD_SHARED_LIBS=ON -DWAVPACK_BUILD_PROGRAMS=ON
- name: Build
run: cmake --build build --parallel
- name: Install
run: sudo cmake --install build
build-test-macos:
name: Build Test macOS
strategy:
fail-fast: false
matrix:
runner: [ 'macos-13', 'macos-latest' ] # Use macos-13 for x86_64.
buildtype: [ 'debug', 'release' ]
runs-on: ${{ matrix.runner }}
steps:
- name: Set arch
run: echo "arch=$(uname -m)" >> $GITHUB_ENV
- name: Set buildtype
run: echo "buildtype=$(echo ${{matrix.buildtype}} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set cmake buildtype
run: echo "cmake_buildtype=$(echo ${{env.buildtype}} | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Configure
run: cmake --log-level="DEBUG" -S . -B build -DCMAKE_BUILD_TYPE="${{env.cmake_buildtype}}" -DBUILD_SHARED_LIBS=ON -DWAVPACK_BUILD_PROGRAMS=ON
- name: Build
run: cmake --build build --config ${{env.cmake_buildtype}} --parallel
- name: Install
run: sudo cmake --install build
windows-binaries:
name: Create Windows binary
runs-on: windows-2022
needs:
- tarball
strategy:
fail-fast: false
matrix:
arch: [ 'x86', 'x86_64' ]
buildtype: [ 'debug', 'release' ]
steps:
- name: Set buildtype
shell: bash
run: echo "buildtype=$(echo ${{matrix.buildtype}} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set cmake buildtype
shell: bash
run: echo "cmake_buildtype=$(echo ${{env.buildtype}} | sed 's/.*/\u&/')" >> $GITHUB_ENV
- name: Set short arch
shell: bash
run: echo "short_arch=$(test "${{matrix.arch}}" = "x86_64" && echo "x64" || echo "${{matrix.arch}}")" >> $GITHUB_ENV
- name: Cleanup PATH
uses: egor-tensin/cleanup-path@v4
with:
dirs: C:\Windows;C:\Windows\system32;C:\Program Files\Git\bin;C:\Program Files\CMake\bin;C:\Program Files\GitHub CLI;C:\ProgramData\Chocolatey\bin
- name: Setup MSVC Environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{matrix.arch}}
sdk: 10.0.20348.0
vsversion: 2022
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: artifact
- name: Set tarball
shell: bash
run: echo "tarball=$(basename $(find artifact/tarball -name '*.xz'))" >> $GITHUB_ENV
- name: Set tarball version
shell: bash
run: echo "tarball_version=$(echo "${{env.tarball}}" | sed -n 's,^wavpack-\([0-9\.]*\)\.tar\..*,\1,p')" >> $GITHUB_ENV
- name: Set release version
if: github.event.release.tag_name == ''
shell: bash
run: echo "release_version=${{env.tarball_version}}" >> $GITHUB_ENV
- name: Set release version
if: github.event.release.tag_name != ''
shell: bash
run: echo "release_version=${{github.event.release.tag_name}}" >> $GITHUB_ENV
- name: Set release name
shell: bash
run: echo "release_name=WavPack-${{env.release_version}}-${{env.short_arch}}-${{env.buildtype}}" >> $GITHUB_ENV
- name: Extract
shell: bash
run: tar -xvf "artifact/tarball/${{env.tarball}}"
- name: Configure
shell: cmd
env:
CL: "/MP"
working-directory: wavpack-${{env.tarball_version}}
run: cmake -S . -B build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE="${{env.cmake_buildtype}}" -DCMAKE_INSTALL_PREFIX="c:\${{env.release_name}}" -DBUILD_SHARED_LIBS=ON -DWAVPACK_BUILD_PROGRAMS=ON
- name: Build
shell: cmd
working-directory: wavpack-${{env.tarball_version}}
run: cmake --build build --config "${{env.cmake_buildtype}}"
- name: Install
shell: cmd
working-directory: wavpack-${{env.tarball_version}}
run: cmake --install build
- name: Create Zip file
shell: cmd
run: 7z a ${{env.release_name}}.zip c:\${{env.release_name}}
- name: List files
shell: cmd
run: 7z l ${{env.release_name}}.zip
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: ${{env.release_name}}
# path: |
# *.zip
add-release-files:
name: Add files to release
if: (success() || failure()) && github.event_name == 'release'
runs-on: ubuntu-latest
needs:
- tarball
- windows-binaries
steps:
- name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: sudo apt install -y git jq gh
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Show release assets
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: gh release view "${{github.event.release.tag_name}}" --json assets | jq -r '.assets[].name'
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: artifact
- name: Add artifact to release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
echo "Release version: ${{github.event.release.tag_name}}"
filenames=()
files=()
for i in $(find artifact -type f); do
filename=$(basename $i)
if [[ ${filenames[@]} =~ ${filename} ]]; then
echo "Skipping duplicate file: ${filename}"
continue
fi
filenames+=("${filename}")
existing_asset=$(gh release view "${{github.event.release.tag_name}}" --json assets | jq -r '.assets[].name' | tr -d '[:blank:]' | grep ".*/${filename}\$" 2>/dev/null || true)
if [ "${existing_asset}" = "" ]; then
echo "Adding file: ${filename}"
files+=("${i}")
else
echo "Release already has file: ${filename}"
fi
done
files_list="${files[@]}"
if ! [ "${files_list}" = "" ]; then
echo "Adding files to GitHub release"
gh release upload "${{github.event.release.tag_name}}" ${files_list}
fi