forked from WasmEdge/WasmEdge
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (96 loc) · 4.5 KB
/
reusable-build-on-windows.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
name: Build on Windows
on:
workflow_call:
inputs:
version:
type: string
required: true
release:
type: boolean
jobs:
build_on_windows:
name: Build on Windows Server 2022
runs-on: windows-2022
env:
build_tests: ON
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure git safe directory
run: |
git config --global --add safe.directory $(pwd)
- name: Install dependency
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install cmake ninja vswhere
- uses: GuillaumeFalourd/[email protected]
with:
sdk-version: 19041
- name: Set environment variables for release
if: ${{ inputs.release }}
run: |
echo "build_tests=OFF" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Build WasmEdge
run: |
$vsPath = (vswhere -latest -property installationPath)
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
$llvm = "LLVM-16.0.6-win64-MultiThreadedDLL.zip"
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-16.0.6/LLVM-16.0.6-win64-MultiThreadedDLL.zip -o $llvm
Expand-Archive -Path $llvm
$llvm_dir = "$pwd\\LLVM-16.0.6-win64-MultiThreadedDLL\\LLVM-16.0.6-win64\\lib\\cmake\\llvm"
$Env:CC = "clang-cl"
$Env:CXX = "clang-cl"
$cmake_sys_version = "10.0.19041.0"
cmake -Bbuild -GNinja "-DCMAKE_SYSTEM_VERSION=$cmake_sys_version" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL "-DLLVM_DIR=$llvm_dir" "-DWASMEDGE_BUILD_TESTS=$Env:build_tests" -DWASMEDGE_BUILD_PACKAGE="ZIP" .
cmake --build build
- name: Test WasmEdge
run: |
$vsPath = (vswhere -latest -property installationPath)
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
$Env:PATH += ";$pwd\\build\\lib\\api"
cd build
tools\wasmedge\wasmedge -v
ctest
cd -
- name: Create WasmEdge package
run: |
$vsPath = (vswhere -latest -property installationPath)
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
cmake --build build --target package
Get-ChildItem -Path "$pwd\\build"
- name: Generate product version and package Windows installer
run: |
$Env:product_version = ("${{ inputs.version }}").split("-")[0]
. "$Env:WIX\bin\candle.exe" -arch x64 -o build\wasmedge.wixobj .github\scripts\wasmedge.wxs
. "$Env:WIX\bin\light.exe" -out build\WasmEdge-$Env:product_version-windows.msi build\wasmedge.wixobj
echo "product_version=$Env:product_version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Upload artifact
if: ${{ !inputs.release }}
uses: actions/upload-artifact@v3
with:
name: WasmEdge-${{ inputs.version }}-windows.zip
path: build\\WasmEdge-${{ inputs.version }}-Windows.zip
- name: Upload Windows installer
if: ${{ !inputs.release }}
uses: actions/upload-artifact@v3
with:
name: WasmEdge-${{ env.product_version }}-windows.msi
path: build\\WasmEdge-${{ env.product_version }}-windows.msi
- name: Upload Windows 10 zip package
if: ${{ inputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv build\\WasmEdge-${{ inputs.version }}-Windows.zip WasmEdge-${{ inputs.version }}-windows.zip
gh release upload ${{ inputs.version }} WasmEdge-${{ inputs.version }}-windows.zip --clobber
- name: Upload Windows installer
if: ${{ inputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv build\\WasmEdge-${{ env.product_version }}-windows.msi WasmEdge-${{ env.product_version }}-windows.msi
gh release upload ${{ inputs.version }} WasmEdge-${{ env.product_version }}-windows.msi --clobber