mirror of
https://github.com/FalloutCollaborationProject/FCP-Mod-Updater.git
synced 2026-07-27 17:04:05 -07:00
Add Update Scripts
This commit is contained in:
@@ -27,11 +27,14 @@ jobs:
|
||||
run: dotnet test --configuration Release
|
||||
|
||||
- name: Build Windows x64 (self-contained)
|
||||
run: dotnet publish FCPModUpdater.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/win-x64-sc
|
||||
run: |
|
||||
dotnet publish FCPModUpdater.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/win-x64-sc
|
||||
cp ./update-fcp-mod-manager.bat ./publish/win-x64-sc/
|
||||
|
||||
- name: Build Linux x64 (self-contained)
|
||||
run: |
|
||||
dotnet publish FCPModUpdater.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/linux-x64-sc
|
||||
cp ./update-fcp-mod-manager.sh ./publish/linux-x64-sc/
|
||||
cp ./fcp-mod-manager.desktop ./publish/linux-x64-sc/
|
||||
|
||||
- name: Build Windows x64 (framework-dependent)
|
||||
@@ -44,11 +47,14 @@ jobs:
|
||||
|
||||
- name: Create archives
|
||||
run: |
|
||||
cp ./update-fcp-mod-manager.bat ./publish/
|
||||
cp ./update-fcp-mod-manager.sh ./publish/
|
||||
cd ./publish
|
||||
zip -r "${{ env.APP_NAME }}-win-x64-selfcontained.zip" win-x64-sc
|
||||
tar -czvf "${{ env.APP_NAME }}-linux-x64-selfcontained.tar.gz" linux-x64-sc
|
||||
zip -r "${{ env.APP_NAME }}-win-x64.zip" win-x64-fd
|
||||
tar -czvf "${{ env.APP_NAME }}-linux-x64.tar.gz" linux-x64-fd
|
||||
sha256sum "${{ env.APP_NAME }}"-*.zip "${{ env.APP_NAME }}"-*.tar.gz > checksums.txt
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
@@ -60,3 +66,6 @@ jobs:
|
||||
./publish/${{ env.APP_NAME }}-linux-x64-selfcontained.tar.gz
|
||||
./publish/${{ env.APP_NAME }}-win-x64.zip
|
||||
./publish/${{ env.APP_NAME }}-linux-x64.tar.gz
|
||||
./publish/checksums.txt
|
||||
./publish/update-fcp-mod-manager.bat
|
||||
./publish/update-fcp-mod-manager.sh
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#!/bin/bash
|
||||
APP_NAME="FCPModUpdater"
|
||||
mkdir -p ./publish
|
||||
cp ./update-fcp-mod-manager.bat ./publish/
|
||||
cp ./update-fcp-mod-manager.sh ./publish/
|
||||
|
||||
# Self-contained
|
||||
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/win-x64-sc ./FCPModUpdater.csproj
|
||||
dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true -o ./publish/linux-x64-sc ./FCPModUpdater.csproj
|
||||
cp ./update-fcp-mod-manager.bat ./publish/win-x64-sc/
|
||||
cp ./update-fcp-mod-manager.sh ./publish/linux-x64-sc/
|
||||
cp ./fcp-mod-manager.desktop ./publish/linux-x64-sc/
|
||||
|
||||
# Archive self-contained builds
|
||||
@@ -21,4 +26,5 @@ cp ./fcp-mod-manager.desktop ./publish/linux-x64-fd/
|
||||
cd ./publish
|
||||
zip -r "${APP_NAME}-win-x64.zip" win-x64-fd
|
||||
tar -czvf "${APP_NAME}-linux-x64.tar.gz" linux-x64-fd
|
||||
sha256sum "${APP_NAME}"-*.zip "${APP_NAME}"-*.tar.gz > checksums.txt
|
||||
cd ..
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
if /I not "%~1"=="--from-temp" (
|
||||
set "TEMP_SCRIPT=%TEMP%\update-fcp-mod-manager-%RANDOM%%RANDOM%.bat"
|
||||
copy "%~f0" "%TEMP_SCRIPT%" >nul
|
||||
call "%TEMP_SCRIPT%" --from-temp
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
del "%TEMP_SCRIPT%" >nul 2>nul
|
||||
exit /b %EXIT_CODE%
|
||||
)
|
||||
|
||||
set "APP_NAME=FCPModUpdater.exe"
|
||||
set "ARCHIVE=FCPModUpdater-win-x64-selfcontained.zip"
|
||||
set "BASE_URL=https://github.com/FalloutCollaborationProject/FCP-Mod-Updater/releases/latest/download"
|
||||
set "STAGING=%TEMP%\FCPModUpdater-update-%RANDOM%%RANDOM%"
|
||||
|
||||
if not exist ".\%APP_NAME%" (
|
||||
echo Run this script from the existing FCP Mod Manager install folder.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
tasklist /FI "IMAGENAME eq %APP_NAME%" 2>nul | find /I "%APP_NAME%" >nul
|
||||
if "%ERRORLEVEL%"=="0" (
|
||||
echo FCP Mod Manager is still running. Close it before updating.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
mkdir "%STAGING%" >nul 2>nul
|
||||
if not exist "%STAGING%" (
|
||||
echo Could not create update staging folder.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Downloading latest FCP Mod Manager release...
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri '%BASE_URL%/%ARCHIVE%' -OutFile '%STAGING%\%ARCHIVE%'; Invoke-WebRequest -Uri '%BASE_URL%/checksums.txt' -OutFile '%STAGING%\checksums.txt'"
|
||||
if not "%ERRORLEVEL%"=="0" (
|
||||
echo Download failed.
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "EXPECTED="
|
||||
for /f "tokens=1" %%A in ('findstr /I /C:" %ARCHIVE%" "%STAGING%\checksums.txt"') do set "EXPECTED=%%A"
|
||||
|
||||
if "%EXPECTED%"=="" (
|
||||
echo Could not find checksum for %ARCHIVE%.
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "ACTUAL="
|
||||
for /f %%A in ('powershell -NoProfile -ExecutionPolicy Bypass -Command "(Get-FileHash -Algorithm SHA256 '%STAGING%\%ARCHIVE%').Hash.ToLowerInvariant()"') do set "ACTUAL=%%A"
|
||||
|
||||
if /I not "%ACTUAL%"=="%EXPECTED%" (
|
||||
echo Checksum verification failed. Update was not installed.
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive -Force -Path '%STAGING%\%ARCHIVE%' -DestinationPath '%STAGING%'"
|
||||
if not "%ERRORLEVEL%"=="0" (
|
||||
echo Could not extract update archive.
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%STAGING%\win-x64-sc" (
|
||||
echo Downloaded archive did not contain the expected win-x64-sc folder.
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Installing update...
|
||||
robocopy "%STAGING%\win-x64-sc" "%CD%" /E /COPY:DAT /R:3 /W:1 /NFL /NDL
|
||||
set "COPY_EXIT=%ERRORLEVEL%"
|
||||
rmdir /S /Q "%STAGING%" >nul 2>nul
|
||||
|
||||
if %COPY_EXIT% GEQ 8 (
|
||||
echo Update copy failed.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Update complete. Start FCP Mod Manager normally.
|
||||
exit /b 0
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_NAME="FCPModUpdater"
|
||||
ARCHIVE="FCPModUpdater-linux-x64-selfcontained.tar.gz"
|
||||
BASE_URL="https://github.com/FalloutCollaborationProject/FCP-Mod-Updater/releases/latest/download"
|
||||
|
||||
if [[ "${1:-}" != "--from-temp" ]]; then
|
||||
temp_script="$(mktemp)"
|
||||
cp "$0" "${temp_script}"
|
||||
set +e
|
||||
bash "${temp_script}" --from-temp
|
||||
exit_code=$?
|
||||
set -e
|
||||
rm -f "${temp_script}"
|
||||
exit "${exit_code}"
|
||||
fi
|
||||
|
||||
if [[ ! -f "./${APP_NAME}" ]]; then
|
||||
echo "Run this script from the existing FCP Mod Manager install folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if pgrep -x "${APP_NAME}" >/dev/null 2>&1; then
|
||||
echo "FCP Mod Manager is still running. Close it before updating."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for tool in curl tar sha256sum; do
|
||||
if ! command -v "${tool}" >/dev/null 2>&1; then
|
||||
echo "Missing required tool: ${tool}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -w "." ]]; then
|
||||
echo "This install folder is not writable. Move the app to a writable folder or update manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
staging="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "${staging}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Downloading latest FCP Mod Manager release..."
|
||||
curl -fsSL "${BASE_URL}/${ARCHIVE}" -o "${staging}/${ARCHIVE}"
|
||||
curl -fsSL "${BASE_URL}/checksums.txt" -o "${staging}/checksums.txt"
|
||||
|
||||
cd "${staging}"
|
||||
if ! grep " ${ARCHIVE}$" checksums.txt | sha256sum -c -; then
|
||||
echo "Checksum verification failed. Update was not installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -xzf "${ARCHIVE}"
|
||||
source_dir="${staging}/linux-x64-sc"
|
||||
|
||||
if [[ ! -d "${source_dir}" ]]; then
|
||||
echo "Downloaded archive did not contain the expected linux-x64-sc folder."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd - >/dev/null
|
||||
|
||||
echo "Installing update..."
|
||||
cp -R "${source_dir}/." .
|
||||
chmod +x "./${APP_NAME}" "./update-fcp-mod-manager.sh"
|
||||
|
||||
echo "Update complete. Start FCP Mod Manager normally."
|
||||
Reference in New Issue
Block a user