-
Notifications
You must be signed in to change notification settings - Fork 521
163 lines (133 loc) · 5.13 KB
/
main.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
name: CI
on: [push, pull_request]
# Cancel any previous workflows if the pull request was updated
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
platform: [x64]
build-cfg: [DebugOpt, Release]
#build-cfg: [Debug, DebugOpt, Release] # our local copy of clang isn't build for debug on linux/macos currently
include:
- os: windows-2022
platform: x64
build-cfg: Debug
runs-on: ${{ matrix.os }}
env:
CC: ${{ startsWith(matrix.os, 'ubuntu') && 'gcc-11' || 'clang' }}
CXX: ${{ startsWith(matrix.os, 'ubuntu') && 'g++-11' || 'clang++' }}
VS_VERSION: "Program Files/Microsoft Visual Studio/2022"
PLATFORM: ${{ matrix.platform }}
BUILD_CONFIGURATION: ${{ matrix.build-cfg }}
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
EMSCRIPTEN_VERSION: 3.1.65
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ env.EMSCRIPTEN_VERSION }}
actions-cache-folder: emsdk-cache-${{ runner.os }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.30.x'
- name: Install nbgv
if: startsWith(matrix.os, 'macos')
run: |
dotnet tool install -g nbgv
- name: Set version
run: nbgv cloud --all-vars
- name: Environment
if: startsWith(matrix.os, 'windows')
shell: bash
run: echo "/c/$VS_VERSION/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH
- name: Setup
shell: bash
run: |
build/build.sh generate -platform $PLATFORM -configuration $BUILD_CONFIGURATION
build/build.sh download_llvm -platform $PLATFORM -configuration $BUILD_CONFIGURATION
- name: Restore
shell: bash
run: build/build.sh restore -platform $PLATFORM -configuration $BUILD_CONFIGURATION
- name: Build
shell: bash
run: build/build.sh -platform $PLATFORM -build_only -configuration $BUILD_CONFIGURATION
- name: Test (.NET)
shell: bash
run: build/test.sh -platform $PLATFORM -configuration $BUILD_CONFIGURATION
- name: Build (QuickJS runtime)
if: runner.os != 'Windows'
shell: bash
run: tests/quickjs/bootstrap.sh
- name: Test (QuickJS)
if: runner.os != 'Windows'
shell: bash
run: tests/quickjs/test.sh -dotnet_configuration $BUILD_CONFIGURATION
- name: Test (Emscripten)
if: runner.os != 'Windows'
shell: bash
run: tests/emscripten/test.sh -dotnet_configuration $BUILD_CONFIGURATION
- name: Pack
shell: bash
run: build/build.sh prepack -platform $PLATFORM -configuration $BUILD_CONFIGURATION
- name: Upload Artifacts
# We only need a release version of this in the create_package job
if: matrix.build-cfg == 'Release'
uses: actions/upload-artifact@v4
with:
name: intermediate-${{ matrix.build-cfg }}-${{ matrix.platform }}
retention-days: 7
overwrite: true
path: |
artifacts
include/**/*.h
create_package:
runs-on: windows-2019
needs: build
if: |
(github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'nuget') || startsWith(github.ref, 'refs/tags/v'))) ||
(github.event.pull_request.head.repo.full_name != github.repository && (contains(github.event.pull_request.head.ref, 'nuget') || startsWith(github.event.pull_request.head.ref, 'refs/tags/v')))
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
BUILD_CONFIGURATION: Release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Set version
run: nbgv cloud --all-vars
- uses: actions/download-artifact@v4
with:
name: intermediate-Release-x64
- name: Setup
shell: bash
run: build/build.sh generate_config -configuration $BUILD_CONFIGURATION
- name: Create package
shell: bash
run: build/build.sh pack -configuration $BUILD_CONFIGURATION
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: CppSharp.nupkg
path: |
artifacts/*.nupkg
- name: Upload package to GitHub Packages
run: |
cd artifacts
dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/mono/index.json" --skip-duplicate
- name: Publish package to nuget.org
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd artifacts
dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source "https://api.nuget.org/v3/index.json" --skip-duplicate