Fix typo in Copy-Item command #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update dependecies | |
on: | |
schedule: | |
# Weekly on saturday at 00:00 UTC | |
- cron: "0 0 * * 6" | |
push: | |
jobs: | |
update-dependencies: | |
name: Update dependencies | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
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" | |
$noitaptacherDirectroyPath = "${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\" | |
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) | |
$tagName = gh release view --repo dextercd/NoitaPatcher --json tagName --jq .tagName | |
$currentTagName = Get-Content -Path ${{ github.workspace }}\mods\noita-mp\lua_modules\lib\lua\5.1\noitapatcher.version | |
echo "NoitaPatcher latest release tagName is $TagName" | |
echo "NoitaPatcher current tagName is $currentTagName" | |
if ($releaseCreatedAt -lt $creationTime -AND $tagName -eq $currentTagName) { | |
echo "NoitaPatcher is up to date" | |
Exit 0 | |
} else { | |
echo "NoitaPatcher is not up to date, downloading latest release $tagName .." | |
gh release download --repo dextercd/NoitaPatcher --pattern "*.zip" --dir "${{ github.workspace }}\temp" | |
} | |
$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 | |
ls -R "${{ github.workspace }}\temp\NoitaPatcher" | |
Copy-Item -Path "${{ github.workspace }}\temp\NoitaPatcher\*" -Destination $noitaptacherDirectroyPath -Recurse -Force -Verbose | |
ls -R $noitaptacherDirectroyPath | |
Copy-Item -Path "${{ github.workspace }}\temp\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" | |
git pull origin dependency-updates | |
git push origin dependency-updates || echo "There are no changes!"; Exit 0 | |
- name: Push changes and create a pull request | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git pull origin dependency-updates | |
$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 | |
} |