-
Notifications
You must be signed in to change notification settings - Fork 3
165 lines (153 loc) · 6.06 KB
/
build.yml
File metadata and controls
165 lines (153 loc) · 6.06 KB
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
name: modapi-launcher-kit
on: [push, pull_request]
jobs:
build:
runs-on: windows-2022
env:
nugetUrl: 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
modApiUrl: 'https://github.com/emd4600/Spore-ModAPI/releases/latest/download/SporeModAPIdlls.zip'
legacyModApiUrl: 'https://github.com/emd4600/Spore-ModAPI/releases/latest/download/SporeModAPIlegacydlls.zip'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86
- name: Install Nuget
run: |
Invoke-WebRequest "${env:nugetUrl}" -OutFile nuget.exe
- name: Prepare Environment
run: |
$env:revision = git describe --tags --always
echo "GIT_REVISION=$env:revision" >> $env:GITHUB_ENV
- name: Restore Packages
run: |
nuget restore
- name: Download Spore-ModAPI
run: |
Invoke-WebRequest "${env:modApiUrl}" -OutFile SporeModAPIdlls.zip
Invoke-WebRequest "${env:legacyModApiUrl}" -OutFile SporeModAPIlegacydlls.zip
- name: Build modapi-launcher-kit
run: |
msbuild /p:Configuration=Release /m
- name: Remove PDB and XML files
run: |
remove-item Output\* -include *.pdb
remove-item Output\* -include *.xml
- name: Package ModApiUpdate.zip
run: |
& "C:\Program Files\7-Zip\7z.exe" e -y SporeModAPIdlls.zip -oOutput\coreLibs
& "C:\Program Files\7-Zip\7z.exe" e -y SporeModAPIlegacydlls.zip -oOutput\
cd Output
& "C:\Program Files\7-Zip\7z" a -tzip "..\ModApiUpdate.zip" *
- name: Build ModAPI.InterimSetup
run: |
Copy -Force ModApiUpdate.zip Package\ModAPI.InterimSetup\Resources\ModApiUpdate.zip
msbuild Package\ModAPI.InterimSetup /p:Configuration=Release
- name: Build ModAPI.Updater
run: |
Copy -Force ModApiUpdate.zip Package\ModAPI.Updater\Resources\ModApiUpdate.zip
msbuild Package\ModAPI.Updater /p:Configuration=Release
- name: Upload ModAPI.InterimSetup
uses: actions/upload-artifact@v6
with:
name: ModAPI.InterimSetup-${{ env.GIT_REVISION }}
path: Package/ModAPI.InterimSetup/bin/Release/*.exe
- name: Upload ModAPI.Updater
uses: actions/upload-artifact@v6
with:
name: ModAPI.Updater-${{ env.GIT_REVISION }}
path: Package/ModAPI.Updater/bin/Release/*.exe
publish-github:
runs-on: windows-2022
needs: [ build ]
if: github.ref_type == 'tag'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prepare Environment
run: |
$env:revision = git describe --tags --always
echo "GIT_REVISION=$env:revision" >> $env:GITHUB_ENV
- name: Download ModAPI.InterimSetup
uses: actions/download-artifact@v7
with:
name: ModAPI.InterimSetup-${{ env.GIT_REVISION }}
path: artifact
- name: Download ModAPI.Updater
uses: actions/download-artifact@v7
with:
name: ModAPI.Updater-${{ env.GIT_REVISION }}
path: artifact
- name: Generate update.info
run: |
$updaterVersion = "1.0.0.0"
$version = (($env:GIT_REVISION -split '\.')[0] -split 'v')[1] + "." `
+ (($env:GIT_REVISION -split '\.')[1]) + "." `
+ (($env:GIT_REVISION -split '\.')[2] -split '-')[0] + ".0"
$downloadUrl = $env:GITHUB_SERVER_URL + "/" + $env:GITHUB_REPOSITORY `
+ "/releases/latest/download/ModAPI.Updater.exe"
echo $updaterVersion > update.info
echo $version >> update.info
echo "false" >> update.info
echo $downloadUrl >> update.info
Copy update.info artifact/update.info
- name: Create Draft Release
uses: ncipollo/release-action@v1
with:
draft: true
makeLatest: true
tag: ${{ env.GIT_REVISION }}
artifacts: artifact/*
publish-cloudflare:
runs-on: windows-2022
needs: [ build ]
if: github.ref_type == 'tag'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prepare Environment
run: |
$env:revision = git describe --tags --always
echo "GIT_REVISION=$env:revision" >> $env:GITHUB_ENV
- name: Download ModAPI.Updater
uses: actions/download-artifact@v7
with:
name: ModAPI.Updater-${{ env.GIT_REVISION }}
path: artifact
- name: Generate update.info
run: |
$updaterVersion = "1.0.0.0"
$version = (($env:GIT_REVISION -split '\.')[0] -split 'v')[1] + "." `
+ (($env:GIT_REVISION -split '\.')[1]) + "." `
+ (($env:GIT_REVISION -split '\.')[2] -split '-')[0] + ".0"
$downloadUrl = "https://update.launcherkit.sporecommunity.com/ModAPI.Updater.exe"
echo $updaterVersion > update.info
echo $version >> update.info
echo "false" >> update.info
echo $downloadUrl >> update.info
Copy update.info artifact/update.info
- name: Upload to Cloudflare R2
uses: ryand56/r2-upload-action@v1.4
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: spore-modapi-launcherkit
source-dir: artifact
destination-dir: ./
- name: Purge Cloudflare Cache
env:
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_PURGECACHE_TOKEN: ${{ secrets.CF_PURGECACHE_TOKEN }}
run: |
$params = @{
Method = 'POST'
Uri = "https://api.cloudflare.com/client/v4/zones/$env:CF_ZONE_ID/purge_cache"
Headers = @{Authorization="Bearer $env:CF_PURGECACHE_TOKEN"}
Body = '{"hosts":["update.launcherkit.sporecommunity.com"]}'
}
Invoke-WebRequest @params