-
Notifications
You must be signed in to change notification settings - Fork 3
298 lines (271 loc) · 13.1 KB
/
ci.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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: CI
env:
Revision: ${{ github.run_number }}
GITHUB_REF: "${{ github.ref }}"
NSIS_ROOT: "C:/Program Files (x86)/NSIS"
RELEASE_DIR: artifacts
WINDOWS_TARGET: x86_64-pc-windows-msvc
LINUX_TARGET: x86_64-unknown-linux-gnu
RELEASE_BIN: hc
PROJECT_NAME: hc
RELEASER_VER: 0.11.2
CI_BUILD_NUMBER: ${{ github.run_number }}
on:
push:
branches: [ master ]
tags:
- "v*" # Run when tag matches v*, i.e. v1.0, v20.15.10
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
prepare:
name: Preparation
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Query version number
id: get_version
shell: bash
run: |
echo "using version tag ${GITHUB_REF:11}"
echo "version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
windows_build:
name: Windows Build
needs: [ prepare ]
runs-on: [self-hosted, windows, x64]
steps:
- uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
vs-version: '17.8'
- name: Check third party libs existence
id: check_files
uses: andstor/file-existence-action@v3
with:
files: "c:/external_lib/apr/lib/apr-1.lib"
- name: Copy third party libs
if: steps.check_files.outputs.files_exists == 'true'
run: |
mkdir external_lib
xcopy c:\external_lib external_lib /S /Y
- name: Get third party libs
if: steps.check_files.outputs.files_exists != 'true'
run: |
Invoke-WebRequest -Uri https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.43/pcre2-10.43.zip -OutFile pcre2-10.43.zip
Invoke-WebRequest -Uri https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-win32bin-2.5.0.zip -OutFile expat-win32bin-2.5.0.zip
Invoke-WebRequest -Uri https://dlcdn.apache.org/apr/apr-1.7.4-win32-src.zip -OutFile apr-1.7.4-win32-src.zip
Invoke-WebRequest -Uri https://dlcdn.apache.org/apr/apr-util-1.6.3-win32-src.zip -OutFile apr-util-1.6.3-win32-src.zip
Invoke-WebRequest -Uri https://github.com/openssl/openssl/archive/refs/tags/openssl-3.2.1.zip -OutFile openssl-3.2.1.zip
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/pcre2-10.43.zip", "$PWD")
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/expat-win32bin-2.5.0.zip", "$PWD/Expat")
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/apr-1.7.4-win32-src.zip", "$PWD")
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/apr-util-1.6.3-win32-src.zip", "$PWD")
Add-Type -AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/openssl-3.2.1.zip", "$PWD")
- uses: ilammy/msvc-dev-cmd@v1
- name: Build third party libs
if: steps.check_files.outputs.files_exists != 'true'
shell: cmd
env:
LINK: /cgthreads:8
run: |
cd ./pcre2-10.43/
cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/pcre" -DBUILD_SHARED_LIBS=OFF -DPCRE2_STATIC=ON -DPCRE2_BUILD_TESTS=OFF -DPCRE2_BUILD_PCRE2GREP=OFF -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" -B build -Ax64
cmake --build build --verbose --parallel 8 --config Release
cmake --install build
cd ../openssl-openssl-3.2.1/
perl Configure VC-WIN64A -static --prefix=${{ github.workspace }}/external_lib/openssl no-apps --openssldir=${{ github.workspace }}/external_lib/ssl
nmake
nmake install_sw
cd ../Expat/Source/
cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/expat" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" -B build -Ax64
cmake --build build --verbose --parallel 8 --config Release
cmake --install build
cd ../../apr-1.7.4/
cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/apr" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" -B build -Ax64
cmake --build build --verbose --parallel 8 --config Release
cmake --install build
cd ../apr-util-1.6.3/
set CMAKE_LIBRARY_PATH=${{ github.workspace }}/external_lib/apr/lib;${{ github.workspace }}/external_lib/expat/lib
set CMAKE_INCLUDE_PATH=${{ github.workspace }}/external_lib/apr/include;${{ github.workspace }}/external_lib/expat/include
set OPENSSL_ROOT_DIR=${{ github.workspace }}/external_lib/openssl
set OPENSSL_LIBRARIES=${{ github.workspace }}/external_lib/openssl/lib
set OPENSSL_INCLUDE_DIR=${{ github.workspace }}/external_lib/openssl/include/openssl
cmake -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/external_lib/apr" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="/MP /MT /Ox /Ob2 /Oy /Oi /Ot /GL /Qpar /Zc:wchar_t /Zc:inline /Zc:preprocessor /validate-charset /D NDEBUG" -B build -Ax64
cmake --build build --verbose --parallel 8 --config Release
cmake --install build
cd ..
mkdir c:\external_lib
xcopy external_lib c:\external_lib /S /Y
- run: nuget restore src\linq2hash.sln
- name: Build
working-directory: src
shell: cmd
env:
PROJECT_BASE_PATH: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\src"
BINPLACE_PLACEFILE: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\binplace.txt"
HC_TEST_DIR: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\_tst.net"
RUNNER_CONTEXT: ${{ toJSON(runner) }}
PROGRAM_VERSION: ${{ needs.prepare.outputs.version }}
APR_HOME16: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\external_lib"
run: |
echo "$RUNNER_CONTEXT"
msbuild hc.xml
- name: Packaging
if: endsWith(github.ref, 'merge') == false
env:
PROJECT_BASE_PATH: "${{runner.workspace}}\\${{ env.PROJECT_NAME }}\\src"
PKG_PATH: pkg
run: |
mkdir ${{ env.RELEASE_DIR }}
xcopy ${{ env.PROJECT_BASE_PATH }}\Install\Release ${{ env.RELEASE_DIR }}\* /S /Y
mkdir ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }}
xcopy ${{ env.PROJECT_BASE_PATH }}\x64\Release\ru ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }}\ru\* /S /Y
xcopy ${{ env.PROJECT_BASE_PATH }}\Binplace-x64\Release\${{ env.RELEASE_BIN }}.exe ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }} /S /Y
tar -cvzf .\${{ env.RELEASE_DIR }}\${{ env.RELEASE_BIN }}-${{ needs.prepare.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz -C ${{ env.PROJECT_BASE_PATH }}\${{ env.PKG_PATH }} *
- uses: actions/upload-artifact@v4
if: endsWith(github.ref, 'merge') == false
with:
name: windows
path: ./${{ env.RELEASE_DIR }}
linux_build:
name: Linux Build
needs: [ prepare ]
runs-on: [self-hosted, linux, x64]
strategy:
matrix:
target: [ x86_64-linux-gnu ]
include:
- target: x86_64-linux-gnu
abi: gnu
os: linux
arch: x86_64
steps:
- uses: actions/checkout@v4
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.11.0
- name: Build
run: |
chmod +x ./linux_build.sh
./linux_build.sh ${{ matrix.abi }} ${{ matrix.os }} ${{ matrix.arch }}
env:
HC_VERSION: ${{ needs.prepare.outputs.version }}
- name: Create artifact directory
run: mkdir ${{ env.RELEASE_DIR }}
- name: Packaging
if: endsWith(github.ref, 'merge') == false
run: cp -v ./bin/*.gz ./${{ env.RELEASE_DIR }}/
- uses: actions/upload-artifact@v4
if: endsWith(github.ref, 'merge') == false
with:
name: ${{ matrix.os }}_${{ matrix.abi }}_${{ matrix.arch }}
path: ./${{ env.RELEASE_DIR }}
generate-changelog:
name: Generate changelog
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@main
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
release:
name: GitHub Release
needs: [ windows_build, linux_build, generate-changelog ]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Query version number
id: get_version
shell: bash
run: |
echo "using version tag ${GITHUB_REF:11}"
echo "version=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
body: "${{ needs.generate-changelog.outputs.release_body }}"
- name: Download Windows zip
uses: actions/download-artifact@v4
with:
name: windows
path: windows
- name: Download Linux x86_64 GNU tarball
uses: actions/download-artifact@v4
with:
name: linux_gnu_x86_64
path: linux_gnu_x86_64
- name: Create fake Cargo.toml
run: |
cat >Cargo.toml <<EOL
[package]
name = "${{ env.RELEASE_BIN }}"
version = "${{ steps.get_version.outputs.VERSION }}"
description = "Hash Calculator is the console tool that can calculate about 50 cryptographic hashes of strings and files."
authors = ["egoroff <egoroff@gmail.com>"]
homepage = "https://github.com/aegoroff/hc"
license = "LGPL-3.0"
EOL
- name: Download Releaser
run: |
curl -L -o releaser.tar.gz https://github.com/aegoroff/releaser/releases/download/${{ env.RELEASER_VER }}/releaser-${{ env.RELEASER_VER }}-x86_64-unknown-linux-musl.tar.gz
tar -xf releaser.tar.gz
- name: Create scoop json
run: ${{ github.workspace }}/releaser s -c . -b https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/ -i './windows/' -e ${{ env.RELEASE_BIN }}.exe -u ${{ env.RELEASE_BIN }}.json
- name: Publish scoop json
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.GH_TOKEN }}
with:
source_file: ${{ env.RELEASE_BIN }}.json
destination_repo: 'aegoroff/scoop-bucket'
user_email: 'egoroff@email.com'
user_name: 'aegoroff'
commit_message: "release: ${{ steps.get_version.outputs.VERSION }}"
- name: Release Windows tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.WINDOWS_TARGET }}.tar.gz
- name: Release Windows installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows/${{ env.RELEASE_BIN }}.setup.${{ steps.get_version.outputs.VERSION }}.${{ env.Revision }}.exe
asset_content_type: application/exe
asset_name: ${{ env.RELEASE_BIN }}.setup.${{ steps.get_version.outputs.VERSION }}.${{ env.Revision }}.exe
- name: Release x86_64 Linux GNU tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux_gnu_x86_64/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: ${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ env.LINUX_TARGET }}.tar.gz