-
Notifications
You must be signed in to change notification settings - Fork 14
139 lines (118 loc) · 4.77 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
name: Build / Deploy
on:
push:
pull_request:
types:
- synchronize
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: windows/wooting-rgb-sdk.sln
BUILD_CONFIGURATION: Release
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
os: [macos-latest, ubuntu-24.04]
include:
- os: ${{startsWith(github.ref, 'refs/tags/v') && 'win-signing' || 'windows-latest'}}
target: x64
- os: ${{startsWith(github.ref, 'refs/tags/v') && 'win-signing' || 'windows-latest'}}
target: x86
steps:
- uses: actions/checkout@v4
with:
submodules: true
# This is set specifically to windows prefix so it only runs on the GH Actions runner and not our own
- name: Add MSBuild to PATH (Windows)
if: startsWith(matrix.os, 'windows')
uses: microsoft/setup-msbuild@v2
- name: Install dependencies
uses: ConorMacBride/install-package@v1
with:
brew: hidapi
apt: libhidapi-dev libhidapi-hidraw0
- name: Build (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: cd linux && make CDEFS="-Werror"
- name: Build (Mac)
if: startsWith(matrix.os, 'mac')
run: cd mac && make CDEFS="-Werror"
- name: Build (Windows)
if: startsWith(matrix.os, 'win')
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.target}} ${{env.SOLUTION_FILE_PATH}}
- name: Gen Release name
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
VER=${GITHUB_REF##*v}
OS=${{matrix.os}}
OS_NAME=${OS%-*}
R_TARGET=${{matrix.target}}
TARGET=${R_TARGET:-x64}
echo "TAG_VERSION=$VER" >> $GITHUB_ENV
echo "RELEASE_NAME=wooting-rgb-sdk-v$VER-$OS_NAME-$TARGET" >> $GITHUB_ENV
- name: Init dist
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
mkdir dist
cp src/*.h dist/
- name: Copy dist files (Linux)
if: startsWith(github.ref, 'refs/tags/v') && startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
cp linux/*.pc dist/
cp linux/*.so dist/
- name: Copy dist files (Mac)
if: startsWith(github.ref, 'refs/tags/v') && startsWith(matrix.os, 'mac')
shell: bash
run: |
cp mac/*.pc dist/
cp mac/*.dylib dist/
- name: Copy dist files (Windows)
if: startsWith(github.ref, 'refs/tags/v') && startsWith(matrix.os, 'win')
shell: bash
run: |
# Copy Windows x64 files
cp windows/x64/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk64.dll dist/ || true
cp windows/x64/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk64.lib dist/ || true
cp windows/x64/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk64.pdb dist/ || true
# Copy Windows x86 files
cp windows/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk.dll dist/ || true
cp windows/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk.lib dist/ || true
cp windows/${{env.BUILD_CONFIGURATION}}/wooting-rgb-sdk.pdb dist/ || true
- name: Sign dlls (Windows)
if: startsWith(github.ref, 'refs/tags/v') && startsWith(matrix.os, 'win')
shell: bash
env:
TIMESTAMP: ${{secrets.WIN_EV_CSC_TIMESTAMP}}
CERT_FILE: ${{secrets.WIN_EV_CSC_CERT_FILE}}
CRYPT_PROVIDER: ${{secrets.WIN_EV_CSC_CRYPT_PROVIDER}}
READER: ${{secrets.WIN_EV_CSC_READER}}
PASS: ${{secrets.WIN_EV_CSC_PASS}}
CONTAINER: ${{secrets.WIN_EV_CSC_CONTAINER}}
run: |
signtool.exe sign /fd sha256 /td sha256 /tr ${TIMESTAMP}?td=sha256 /f $CERT_FILE /csp "$CRYPT_PROVIDER" /kc "[${READER}{{${PASS}}}]=${CONTAINER}" "dist/wooting-rgb-sdk${{matrix.target == 'x64' && '64' || ''}}.dll"
signtool.exe verify /pa "dist/wooting-rgb-sdk${{matrix.target == 'x64' && '64' || ''}}.dll"
- name: Zip files
if: startsWith(github.ref, 'refs/tags/v')
uses: vimtor/[email protected]
with:
files: dist/
recursive: true
dest: ${{env.RELEASE_NAME}}.zip
- name: Make Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: ${{env.RELEASE_NAME}}.zip
token: ${{ secrets.GITHUB_TOKEN }}
draft: true