-
Notifications
You must be signed in to change notification settings - Fork 1
263 lines (235 loc) · 9.74 KB
/
release.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: Generate Release
on:
release:
types: [published]
permissions:
contents: write
jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Ubuntu
- os: ubuntu-latest
arch: x86_64
compiler: gcc
- os: ubuntu-latest
arch: arm64
compiler: gcc
# macOS
- os: macos-latest
arch: x86_64
compiler: gcc
- os: macos-latest
arch: arm64
compiler: gcc
# Windows
- os: windows-latest
arch: x86_64
compiler: msvc
- os: windows-latest
arch: x86_64
compiler: mingw
name: Build on ${{ matrix.os }} for ${{ matrix.arch }} using ${{ matrix.compiler }}
steps:
- name: Checkout code
uses: actions/checkout@v3
# Read version on Unix-based systems
- name: Read version (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
source VERSION
echo "VERSION_MAJOR=$VERSION_MAJOR" >> $GITHUB_ENV
echo "VERSION_MINOR=$VERSION_MINOR" >> $GITHUB_ENV
echo "VERSION_PATCH=$VERSION_PATCH" >> $GITHUB_ENV
echo "VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH" >> $GITHUB_ENV
# Read version on Windows systems
- name: Read version (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$versionContent = Get-Content VERSION
foreach ($line in $versionContent) {
if ($line -match 'VERSION_MAJOR=(.*)') { $env:VERSION_MAJOR = $Matches[1] }
if ($line -match 'VERSION_MINOR=(.*)') { $env:VERSION_MINOR = $Matches[1] }
if ($line -match 'VERSION_PATCH=(.*)') { $env:VERSION_PATCH = $Matches[1] }
}
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_MAJOR=$($env:VERSION_MAJOR)"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_MINOR=$($env:VERSION_MINOR)"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_PATCH=$($env:VERSION_PATCH)"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION=$($env:VERSION_MAJOR).$($env:VERSION_MINOR).$($env:VERSION_PATCH)"
# Set Release Name on Unix systems
- name: Set Release Name (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [[ "${{ matrix.os }}" == *"ubuntu"* ]]; then
OS_NAME="linux"
elif [[ "${{ matrix.os }}" == *"macos"* ]]; then
OS_NAME="macos"
else
OS_NAME="${{ matrix.os }}"
fi
echo "RELEASE_NAME=libcardano-c-${{ env.VERSION }}-${OS_NAME}-${{ matrix.arch }}-${{ matrix.compiler }}" >> $GITHUB_ENV
# Set Release Name on Windows systems
- name: Set Release Name (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$osName = if ($env:RUNNER_OS -eq "Windows") { "windows" } else { $env:RUNNER_OS }
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_NAME=libcardano-c-${{ env.VERSION }}-${osName}-${{ matrix.arch }}-${{ matrix.compiler }}"
# Install dependencies for Unix
- name: Install dependencies (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
sudo apt-get update
case "${{ matrix.arch }}" in
arm64) sudo apt-get install -y gcc-aarch64-linux-gnu ;;
esac
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
# CMake is already installed on macOS runners
cmake --version
fi
# Install dependencies for Windows (MinGW from niXman)
- name: Install dependencies (Windows MinGW from niXman)
if: runner.os == 'Windows' && matrix.compiler == 'mingw'
shell: pwsh
run: |
$MingwVersion = "x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0"
$MingwUrl = "https://github.com/niXman/mingw-builds-binaries/releases/download/14.2.0-rt_v12-rev0/$MingwVersion.7z"
$MingwDir = "$env:RUNNER_TEMP\mingw-w64"
Invoke-WebRequest -Uri $MingwUrl -OutFile "$env:RUNNER_TEMP\$MingwVersion.7z"
7z x "$env:RUNNER_TEMP\$MingwVersion.7z" -o$MingwDir
"$MingwDir\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Setup MSVC environment
- name: Setup MSVC environment
if: runner.os == 'Windows' && matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
# Build on Unix systems
- name: Build (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
case "${{ matrix.arch }}" in
arm64)
cmake -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DVERSION_MAJOR=${{ env.VERSION_MAJOR }} \
-DVERSION_MINOR=${{ env.VERSION_MINOR }} \
-DVERSION_PATCH=${{ env.VERSION_PATCH }} \
-DCMAKE_BUILD_TYPE=Release \
.
;;
x86_64)
cmake -DCMAKE_SYSTEM_PROCESSOR=x86_64 \
-DVERSION_MAJOR=${{ env.VERSION_MAJOR }} \
-DVERSION_MINOR=${{ env.VERSION_MINOR }} \
-DVERSION_PATCH=${{ env.VERSION_PATCH }} \
-DCMAKE_BUILD_TYPE=Release \
.
;;
esac
cmake --build . --config Release
# Build on Windows MSVC
- name: Build (Windows MSVC)
if: runner.os == 'Windows' && matrix.compiler == 'msvc'
shell: cmd
run: |
cmake -G "Visual Studio 17 2022" -A x64 ^
-DVERSION_MAJOR=%VERSION_MAJOR% ^
-DVERSION_MINOR=%VERSION_MINOR% ^
-DVERSION_PATCH=%VERSION_PATCH% ^
.
cmake --build . --config Release
# Build on Windows MinGW (Without Clang-Tidy for MinGW builds for now)
- name: Build (Windows MinGW)
if: runner.os == 'Windows' && matrix.compiler == 'mingw'
shell: bash
run: |
cmake -G "MinGW Makefiles" \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_C_FLAGS="-I${{ github.workspace }}/lib/include \
-I${{ github.workspace }}/lib \
-I${{ github.workspace }}/lib/external \
-I${{ github.workspace }}/lib/external/libsodium \
-I${{ github.workspace }}/lib/external/libsodium/include \
-I${{ github.workspace }}/lib/external/gmp \
-I${{ github.workspace }}/lib/external/json-c" \
-DVERSION_MAJOR=${{ env.VERSION_MAJOR }} \
-DVERSION_MINOR=${{ env.VERSION_MINOR }} \
-DVERSION_PATCH=${{ env.VERSION_PATCH }} \
-DCMAKE_BUILD_TYPE=Release \
.
cmake --build . --config Release
# Package binaries (Unix)
- name: Package binaries (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
RELEASE_DIR=release/${{ env.RELEASE_NAME }}
mkdir -p $RELEASE_DIR/lib
cp README.md $RELEASE_DIR/
cp COPYING $RELEASE_DIR/LICENSE
cp -r lib/include $RELEASE_DIR/
cp build/release/lib/*.so $RELEASE_DIR/lib 2>/dev/null || true
cp build/release/lib/*.dylib $RELEASE_DIR/lib 2>/dev/null || true
cp build/release/lib/*.a $RELEASE_DIR/lib 2>/dev/null || true
cp build/release/lib/*.pc $RELEASE_DIR/lib 2>/dev/null || true
tar -czf "${{ env.RELEASE_NAME }}.tar.gz" -C release/${{ env.RELEASE_NAME }} .
# Package binaries (Windows MSVC)
- name: Package binaries (Windows MSVC)
if: runner.os == 'Windows' && matrix.compiler == 'msvc'
shell: cmd
run: |
set RELEASE_DIR=release\%RELEASE_NAME%
mkdir %RELEASE_DIR%
mkdir %RELEASE_DIR%\lib
xcopy /E /I lib\include %RELEASE_DIR%\include
for %%f in (dll lib) do (
xcopy /Y build\release\lib\Release\*.%%f %RELEASE_DIR%\lib\
)
xcopy /Y README.md %RELEASE_DIR%\
xcopy /Y COPYING %RELEASE_DIR%\LICENSE
powershell Compress-Archive -Path %RELEASE_DIR%\* -DestinationPath %RELEASE_NAME%.zip
# Package binaries (Windows MinGW)
- name: Package binaries (Windows MinGW)
if: runner.os == 'Windows' && matrix.compiler == 'mingw'
shell: bash
run: |
RELEASE_DIR=${{ env.RELEASE_NAME }}
mkdir -p $RELEASE_DIR/lib
cp -r lib/include $RELEASE_DIR/
cp README.md $RELEASE_DIR/
cp COPYING $RELEASE_DIR/LICENSE
cp build/release/lib/*.dll $RELEASE_DIR/lib 2>/dev/null || true
cp build/release/lib/*.dll.a $RELEASE_DIR/lib 2>/dev/null || true
cd $RELEASE_DIR
7z a "../${{ env.RELEASE_NAME }}.zip" *
cd ..
# Upload artifacts to GitHub Release (Unix)
- name: Upload artifacts to GitHub Release (Unix)
if: runner.os != 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.RELEASE_NAME }}.tar.gz
asset_name: ${{ env.RELEASE_NAME }}.tar.gz
asset_content_type: application/gzip
# Upload artifacts to GitHub Release (Windows)
- name: Upload artifacts to GitHub Release (Windows)
if: runner.os == 'Windows'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.RELEASE_NAME }}.zip
asset_name: ${{ env.RELEASE_NAME }}.zip
asset_content_type: application/zip