-
-
Notifications
You must be signed in to change notification settings - Fork 12
187 lines (159 loc) · 9 KB
/
dependency-updater.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
name: Update dependecies
on:
schedule:
# Weekly on saturday at 00:00 UTC
- cron: "0 0 * * 6"
jobs:
update-dependencies:
name: Update dependencies
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
ref: develop
fetch-depth: 0
- name: Checkout or create new branch 'dependency-updates'
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
git remote update
git fetch
git checkout -b dependency-updates origin/develop
# - name: Install and init luarocks
# shell: cmd
# run: |
# cd ${{ github.workspace}}\mods\noita-mp\
# set INIT_PATH=%CD%
# REM // resolve absolute path
# set REL_PATH=..\..\.building\luarocks-3.9.1-windows-32
# set ABS_PATH=
# rem // Save current directory and change to target directory
# pushd %REL_PATH%
# rem // Save value of CD variable (current directory)
# set ABS_PATH=%CD%
# rem // Restore original directory
# popd
# echo Relative path: %REL_PATH%
# echo Maps to path: %ABS_PATH%
# REM // init luarocks
# %ABS_PATH%\luarocks --lua-dir="${{ github.workspace}}\LuaJIT-2.0.4" --lua-version="5.1" init noita-mp --output="${{ github.workspace}}\mods\noita-mp" --homepage="https://github.com/Ismoh/NoitaMP" --lua-versions="5.1" --license="GNU GPL v3"
# REM // change luarocks projects config
# %ABS_PATH%\luarocks config --scope="project" lua_interpreter luajit.exe
# %ABS_PATH%\luarocks config --scope="project" lua_dir ${{ github.workspace}}\LuaJIT-2.0.4
# %ABS_PATH%\luarocks config --scope="project" variables.LUA_BINDIR ${{ github.workspace}}\LuaJIT-2.0.4\bin
# %ABS_PATH%\luarocks config --scope="project" variables.LUA_DIR ${{ github.workspace}}\LuaJIT-2.0.4
# %ABS_PATH%\luarocks config --scope="project" variables.LUA_INCDIR ${{ github.workspace}}\LuaJIT-2.0.4\include
# %ABS_PATH%\luarocks config --scope="project" variables.CFLAGS "GODDAMNIT"
# %ABS_PATH%\luarocks config
# if exist lua.bat (
# echo "LuaRocks project init successfully"
# ) else (
# echo "::error::LuaRocks project init failed. Unable to find lua.bat"
# exit 1
# )
# if exist luarocks.bat (
# echo "LuaRocks project init successfully"
# ) else (
# echo "::error::LuaRocks project init failed. Unable to find luarocks.bat"
# exit 1
# )
# - name: Fix LuaRocks bug
# env:
# GH_TOKEN: ${{ github.token }}
# run: |
# cd ${{ github.workspace}}\mods\noita-mp\.luarocks
# sed -i 's/GODDAMNIT/\-v \-O2/g' config-5.1.lua
# cat config-5.1.lua
# - name: Update LuaRocks
# # env:
# # GH_TOKEN: ${{ github.token }}
# shell: cmd
# run: |
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
# cd ${{ github.workspace }}\mods\noita-mp\
# # luarocks install --only-deps ${{ github.workspace }}\mods\noita-mp\noita-mp-3.0.0-3.rockspec
# git commit -m "Updated LuaRocks dependencies" -a || echo "No changes to commit"
- name: Update NoitaPatcher
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$noitaptacherPath = "${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.dll"
if ([System.IO.File]::Exists($noitaptacherPath)) {
$creationTime = (Get-Item $noitaptacherPath).CreationTime.ToString("yyyy-MM-ddThh:mm:ssZ")
} else {
$creationTime = "2021-11-10T00:00:00Z"
}
$creationTime = [Datetime]::ParseExact($creationTime, "yyyy-MM-ddThh:mm:ssZ", $null)
$releaseCreatedAt = gh release view --repo dextercd/NoitaPatcher --json createdAt --jq .createdAt
$releaseCreatedAt = [Datetime]$releaseCreatedAt
echo "NoitaPatcher was created at $creationTime"
echo "Latest release was created at $releaseCreatedAt"
echo ($releaseCreatedAt -lt $creationTime)
if ($releaseCreatedAt -lt $creationTime) {
echo "NoitaPatcher is up to date"
Exit 0
} else {
gh release download --repo dextercd/NoitaPatcher --pattern "*.zip" --dir "${{ github.workspace }}\temp"
}
$tagName = gh release view --repo dextercd/NoitaPatcher --json tagName --jq .tagName
$tagName | Out-File -FilePath ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.version
Expand-Archive -Path "${{ github.workspace }}\temp\NoitaPatcher*.zip" -DestinationPath "${{ github.workspace }}\temp" -Force
Copy-Item -Path "${{ github.workspace }}\temp\NoitaPatcher\noitapatcher.dll" -Destination $noitaptacherPath -Force
Copy-Item -Path "${{ github.workspace }}\temp\NoitaPatcher\modules\noitapatcher.lua" -Destination "${{ github.workspace }}\.debug\lua-definitions" -Force
cd ${{ github.workspace }} # go back to root otherwise we cannot delete the temp folder
Remove-Item -Path "${{ github.workspace }}\temp" -Recurse -Force
git add ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.version
git add -f $noitaptacherPath
git add "${{ github.workspace }}\.debug\lua-definitions\noitapatcher.lua"
git commit -m "Updated NoitaPatcher dependencies" -a || echo "No changes to commit"; Exit 0
- name: Update Noita-Synchronise-Expansive-Worlds
env:
GH_TOKEN: ${{ github.token }}
run: |
$nsewPath = "${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\nsew_native.dll"
if ([System.IO.File]::Exists($neswPath)) {
$creationTime = (Get-Item $nsewPath).CreationTime.ToString("yyyy-MM-ddThh:mm:ssZ")
} else {
$creationTime = "2021-11-10T00:00:00Z"
}
$creationTime = [Datetime]::ParseExact($creationTime, "yyyy-MM-ddThh:mm:ssZ", $null)
$releaseCreatedAt = gh release view --repo dextercd/Noita-Synchronise-Expansive-Worlds --json createdAt --jq .createdAt
$releaseCreatedAt = [Datetime]$releaseCreatedAt
echo "Noita-Synchronise-Expansive-Worlds was created at $creationTime"
echo "Latest release was created at $releaseCreatedAt"
echo ($releaseCreatedAt -lt $creationTime)
if ($releaseCreatedAt -lt $creationTime) {
echo "Noita-Synchronise-Expansive-Worlds is up to date"
Exit 0
} else {
gh release download --repo dextercd/Noita-Synchronise-Expansive-Worlds --pattern "*.zip" --dir "${{ github.workspace }}\temp"
}
$tagName = gh release view --repo dextercd/Noita-Synchronise-Expansive-Worlds --json tagName --jq .tagName
$tagName | Out-File -FilePath ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\nsew.version
Expand-Archive -Path "${{ github.workspace }}\temp\nsew-*.zip" -DestinationPath "${{ github.workspace }}\temp\nsew" -Force
Copy-Item -Path "${{ github.workspace }}\temp\nsew\nsew\nsew_native.dll" -Destination $nsewPath -Force
if (![System.IO.File]::Exists("${{ github.workspace }}\mods\noita-mp\lua_modules\share\lua\5.1\nsew")) {
New-Item -Path "${{ github.workspace }}\mods\noita-mp\lua_modules\share\lua\5.1\nsew" -ItemType Directory -Force
}
Copy-Item -Path "${{ github.workspace }}\temp\nsew\nsew\*.lua" -Destination "${{ github.workspace }}\mods\noita-mp\lua_modules\share\lua\5.1\nsew" -Force
cd ${{ github.workspace }} # go back to root otherwise we cannot delete the temp folder
Remove-Item -Path "${{ github.workspace }}\temp" -Recurse -Force
git add ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\nsew.version
git add -f $nsewPath
git add -f "${{ github.workspace }}\mods\noita-mp\lua_modules\share\lua\5.1\nsew\*.lua"
git commit -m "Updated nsew dependencies" -a || echo "No changes to commit"; Exit 0
- name: Push changes and create a pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
git pull origin dependency-updates
git push origin dependency-updates || echo "There are no changes!"; Exit 0
$prTitleArray = gh pr list --head "dependency-updates" --json "title" | ConvertFrom-Json
if ($prTitleArray.Count -gt 0) {
echo "PR already exists. Nothing to do!"
} else {
gh pr create --title "Update dependencies" --body "This PR was automatically created by the dependency updater workflow. Resolves #117" --base develop --head dependency-updates --assignee Ismoh --reviewer Ismoh
}