-
-
Notifications
You must be signed in to change notification settings - Fork 20
162 lines (134 loc) · 5.27 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Build Dev
on:
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
env:
DOTNET_INSTALL_DIR: ./dotnet
DOTNET_VERSION: 8.0.x
RUN_TESTS: false
jobs:
build-android:
runs-on: ubuntu-latest
env:
PLATFORM: x64
CONFIG_NAME: Android_Debug
RELEASE_TAG_NAME: android_dev_debug
RELEASE_NAME: Android-Dev
# If true, the dotnet workload of WORKLOAD_NAME will be installed.
INSTALL_WORKLOAD: true
TARGET_WINDOWS: false
WORKLOAD_NAME: android
steps:
- name: Checkout Git Repo
uses: actions/checkout@v3
- name: Get Current Date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cache dotnet
id: cache-dotnet
uses: actions/cache@v3
with:
path: ${{ env.DOTNET_INSTALL_DIR }}
key: ${{ runner.os }}-dotnet-${{ env.DOTNET_VERSION }}-${{ env.CONFIG_NAME }}
restore-keys: ${{ runner.os }}-dotnet-${{ env.DOTNET_VERSION }}-${{ env.CONFIG_NAME }}
- name: Install .NET [${{ env.DOTNET_VERSION }}]
if: ${{ steps.cache-dotnet.outputs.cache-hit != 'true' }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install [${{ env.WORKLOAD_NAME }}] workload
if: ${{ env.INSTALL_WORKLOAD == 'true' }}
run: dotnet workload install ${{ env.WORKLOAD_NAME }}
- name: Run Tests
if: ${{ env.RUN_TESTS == 'true' }}
run: dotnet test --no-build --verbosity normal
- name: Build Debug
run: dotnet build /p:Platform="$PLATFORM" /p:EnableWindowsTargeting=$TARGET_WINDOWS --configuration $CONFIG_NAME
- name: Publish Artifacts
run: dotnet publish /p:EnableWindowsTargeting=$TARGET_WINDOWS --configuration $CONFIG_NAME --output ./publish_$CONFIG_NAME
- name: Zip build output
run: zip -r $RELEASE_TAG_NAME.zip ./publish_$CONFIG_NAME
- name: Create Release [${{ env.RELEASE_NAME }}]
id: build_create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG_NAME }}-${{ steps.date.outputs.date }}
release_name: ${{ env.RELEASE_NAME }}-${{ steps.date.outputs.date }}
body: |
This is the ${{ env. CONFIG_NAME }} build.
draft: false
prerelease: true
- name: Upload Release Asset [${{ env.RELEASE_TAG_NAME }}.zip]
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.build_create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_TAG_NAME }}.zip
asset_name: ${{ env.RELEASE_TAG_NAME }}.zip
asset_content_type: application/zip
build-windows:
runs-on: ubuntu-latest
env:
PLATFORM: x64
CONFIG_NAME: Debug
RELEASE_TAG_NAME: windows_dev_debug
RELEASE_NAME: Windows-dev
# If true, the dotnet workload of WORKLOAD_NAME will be installed.
INSTALL_WORKLOAD: false
TARGET_WINDOWS: true
WORKLOAD_NAME: none
steps:
- name: Checkout Git Repo
uses: actions/checkout@v4
- name: Get Current Date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Cache dotnet
id: cache-dotnet
uses: actions/cache@v3
with:
path: ${{ env.DOTNET_INSTALL_DIR }}
key: ${{ runner.os }}-dotnet-${{ env.DOTNET_VERSION }}-${{ env.CONFIG_NAME }}
restore-keys: ${{ runner.os }}-dotnet-${{ env.DOTNET_VERSION }}-${{ env.CONFIG_NAME }}
- name: Install .NET [${{ env.DOTNET_VERSION }}]
if: ${{ steps.cache-dotnet.outputs.cache-hit != 'true' }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install [${{ env.WORKLOAD_NAME }}] workload
if: ${{ env.INSTALL_WORKLOAD == 'true' }}
run: dotnet workload install ${{ env.WORKLOAD_NAME }}
- name: Run Tests
if: ${{ env.RUN_TESTS == 'true' }}
run: dotnet test --no-build --verbosity normal
- name: Build Debug
run: dotnet build /p:Platform="$PLATFORM" /p:EnableWindowsTargeting=$TARGET_WINDOWS --configuration $CONFIG_NAME
- name: Publish Artifacts
run: dotnet publish /p:EnableWindowsTargeting=$TARGET_WINDOWS --configuration $CONFIG_NAME --output ./publish_$CONFIG_NAME
- name: Zip build output
run: zip -r $RELEASE_TAG_NAME.zip ./publish_$CONFIG_NAME
- name: Create Release [${{ env.RELEASE_NAME }}]
id: build_create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG_NAME }}-${{ steps.date.outputs.date }}
release_name: ${{ env.RELEASE_NAME }}-${{ steps.date.outputs.date }}
body: |
This is the ${{ env. CONFIG_NAME }} build.
draft: false
prerelease: true
- name: Upload Release Asset [${{ env.RELEASE_TAG_NAME }}.zip]
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.build_create_release.outputs.upload_url }}
asset_path: ./${{ env.RELEASE_TAG_NAME }}.zip
asset_name: ${{ env.RELEASE_TAG_NAME }}.zip
asset_content_type: application/zip