diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..17e197e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,80 @@ +name: Build Mod Package + +on: + push: + branches: + - main + - master + tags: + - "v*" + pull_request: + workflow_dispatch: + release: + types: + - published + +permissions: + contents: write + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "8.0.x" + + - name: Download latest LSLib release + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + $release = Invoke-RestMethod -Uri "https://api.github.com/repos/Norbyte/lslib/releases/latest" + $asset = $release.assets | Where-Object { $_.name -match '\.zip$' } | Select-Object -First 1 + + if (-not $asset) { + throw "Could not find a downloadable LSLib zip asset in the latest release." + } + + New-Item -ItemType Directory -Path ".tools/lslib" -Force | Out-Null + Invoke-WebRequest -Uri $asset.browser_download_url -OutFile ".tools/lslib/lslib.zip" + Expand-Archive -LiteralPath ".tools/lslib/lslib.zip" -DestinationPath ".tools/lslib" -Force + + - name: Resolve Divine executable + id: divine + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + $divine = Get-ChildItem -Path ".tools/lslib" -Recurse -File | + Where-Object { $_.Name -ieq "Divine.exe" } | + Select-Object -First 1 + + if (-not $divine) { + throw "Divine.exe was not found in the downloaded LSLib release." + } + + "path=$($divine.FullName)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append + + - name: Build .pak + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + New-Item -ItemType Directory -Path "build" -Force | Out-Null + & "${{ steps.divine.outputs.path }}" -a create-package -g bg3 -s Mods -d build/DnD55eRussian.pak + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: DnD55eRussian-pak + path: build/DnD55eRussian.pak + if-no-files-found: error + + - name: Attach package to GitHub Release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v2 + with: + files: build/DnD55eRussian.pak