-
Notifications
You must be signed in to change notification settings - Fork 3
242 lines (199 loc) · 6.72 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
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
name: main
on:
push:
pull_request:
env:
DOTNET_NOLOGO: true # Disable the .NET logo
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry
jobs:
format:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
#- name: Verify formatting
# run: >
# dotnet build
# -t:CSharpierFormat
# --configuration Release
# MAUI Android Build
build-android:
#runs-on: windows-latest
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
name: Android Build
strategy:
matrix:
rid:
- android
- android-arm
- android-arm64
- android-x86
- android-x64
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create keystore file
run: echo "${{ secrets.KEYSTORE_B64 }}" | base64 -d > $GITHUB_WORKSPACE/signing-key.keystore
shell: bash
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install MAUI Workload
#run: dotnet workload install maui --ignore-failed-sources
run: dotnet workload install maui-android
# Setup JDK and Android SDK on Linux
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 22
distribution: adopt
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Restore Dependencies
run: dotnet restore Yosu/
- name: Publish MAUI Android
run: >
dotnet publish Yosu/
-c Release
-f net8.0-android
-p:AndroidKeyStore=true
-p:AndroidSigningKeyStore=${{ github.workspace }}/signing-key.keystore
-p:AndroidSigningStorePass="${{ secrets.PASSWORD }}"
-p:AndroidSigningKeyAlias="YosuAlias"
-p:AndroidSigningKeyPass="${{ secrets.PASSWORD }}"
-p:CSharpier_Bypass=true
${{ startsWith(matrix.rid, 'android-') && format('{0} {1}', '--runtime', matrix.rid) || '' }}
- name: Rename file
run: |
set -e
mv Yosu/bin/Release/net8.0-android${{ startsWith(matrix.rid, 'android-') && format('{0}{1}', '/', matrix.rid) || '' }}/*-Signed.apk Yosu-${{ matrix.rid }}.apk
shell: bash
- name: Upload Android Artifact
uses: actions/upload-artifact@v4
with:
name: Yosu-${{ matrix.rid }}
path: Yosu-${{ matrix.rid }}.apk
release:
if: ${{ github.ref_type == 'tag' }}
needs:
- format
- build-android
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
gh release create ${{ github.ref_name }}
--repo ${{ github.event.repository.full_name }}
--title ${{ github.ref_name }}
--generate-notes
--verify-tag
deploy:
#if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs: build-android
strategy:
matrix:
rid:
- android
- android-arm
- android-arm64
- android-x86
- android-x64
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
steps:
# Checkout required for running git commands, etc.
- name: Checkout
uses: actions/checkout@v4
- name: Set variables
run: |
TAG_NAME="${{ github.ref_name }}"
echo $TAG_NAME
VERSION="$(echo $TAG_NAME | tr -d v)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME.apk" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: Yosu
path: Yosu
- name: Set body
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${GITHUB_REF#refs/*/})
echo "TAG_MESSAGE2<<EOF" >> $GITHUB_ENV
echo "$TAG_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Clean up downloaded artifacts
run: |
set -e
mv Yosu/Yosu.apk ${{ env.PACKAGE_NAME }}
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
gh release create "${{ github.ref_name }}"
"${{ env.PACKAGE_NAME }}"
--repo "${{ github.event.repository.full_name }}"
--title "${{ env.VERSION }}"
--notes "${{ env.TAG_MESSAGE2 }}"
--verify-tag
notify:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set variables
run: |
TAG_NAME="${{ github.ref_name }}"
echo "$TAG_NAME"
echo "PACKAGE_NAME=${{ github.event.repository.name }}-$TAG_NAME.apk" >> $GITHUB_ENV
- name: Set variables 2
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${GITHUB_REF#refs/*/})
# Sanitize content
TAG_MESSAGE="${TAG_MESSAGE//'%'/'%25'}"
TAG_MESSAGE="${TAG_MESSAGE//$'\n'/'\n'}"
TAG_MESSAGE="${TAG_MESSAGE//$'\r'/'\r'}"
TAG_MESSAGE="$TAG_MESSAGE" | sed "s/\"/'/g"
# End sanitization
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
echo "$TAG_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Notify Discord
uses: tyrrrz/action-http-request@v1
with:
url: ${{ secrets.DISCORD_WEBHOOK }}
method: POST
headers: |
Content-Type: application/json; charset=UTF-8
body: |
{
"username": "Notifications",
"avatar_url": "https://raw.githubusercontent.com/${{ github.event.repository.full_name }}/master/favicon.png",
"content": "**${{ github.event.repository.name }}** new version released!\nVersion: `${{ github.ref_name }}`\n\n${{ env.RELEASE_BODY }}\n\nDownload: <${{ github.event.repository.html_url }}/releases/download/${{ github.ref_name }}/${{ env.PACKAGE_NAME }}>"
}