diff --git a/.github/scripts/thunderstore_bundle.js b/.github/scripts/thunderstore_bundle.js index 1446f721d..63f97b9e3 100644 --- a/.github/scripts/thunderstore_bundle.js +++ b/.github/scripts/thunderstore_bundle.js @@ -17,11 +17,11 @@ import json2toml from "json2toml"; import child_process from "child_process"; import XmlReader from "xml-reader"; import xmlQuery from "xml-query"; -import { zip } from 'zip-a-folder'; -import fsepkg from 'fs-extra'; +import { zip } from "zip-a-folder"; +import fsepkg from "fs-extra"; const move = fsepkg.move; const remove = fsepkg.remove; -import * as core from '@actions/core'; +import * as core from "@actions/core"; // Setting it so that it's consistent with installs from thunderstore const NEBULA_RELEASE_FOLDER_NAME = "nebula-NebulaMultiplayerMod"; @@ -36,16 +36,21 @@ const DIST_TSTORE_CLI_CONFIG_PATH = join( ); const PLUGIN_INFO_PATH = "NebulaPatcher\\PluginInfo.cs"; const pluginInfo = getPluginInfo(); -const TSTORE_ARCHIVE_PATH = join(DIST_RELEASE_FOLDER, "nebula-thunderstore.zip"); -const GH_ARCHIVE_PATH = join(DIST_RELEASE_FOLDER, "Nebula_" + pluginInfo.version + ".zip"); +const TSTORE_ARCHIVE_PATH = join( + DIST_RELEASE_FOLDER, + "nebula-thunderstore.zip" +); +const GH_ARCHIVE_PATH = join( + DIST_RELEASE_FOLDER, + "Nebula_" + pluginInfo.version + ".zip" +); const MOD_ICON_PATH = "thunderstore_icon.png"; const README_PATH = "README.md"; const CHANGELOG_PATH = "CHANGELOG.md"; -const NEBULA_BINARIES_FOLDER = getNebulaFolder(); async function main() { if (!existsSync(DIST_NEBULA_FOLDER)) { - mkdirSync(DIST_NEBULA_FOLDER, { recursive: true }); + throw DIST_NEBULA_FOLDER + " does not exist"; } if (!existsSync(DIST_TSTORE_CLI_FOLDER)) { @@ -54,15 +59,14 @@ async function main() { try { generateReleaseBody(); - } catch(err) { + } catch (err) { core.setFailed(err); } - + generateManifest(); copyIcon(); copyReadme(); appendChangelog(); - copyFolderContent(NEBULA_BINARIES_FOLDER, DIST_NEBULA_FOLDER); copyLicenses(); await createTStoreArchive(); @@ -172,8 +176,7 @@ async function doTStoreRelease() { return asset.name.includes("tstore-cli.exe"); } - try - { + try { await downloadRelease( user, repo, @@ -184,11 +187,10 @@ async function doTStoreRelease() { disableLogging ); console.log("Successfully downloaded tstore-cli.exe"); - await new Promise(r => setTimeout(r, 2000)); + await new Promise((r) => setTimeout(r, 2000)); generateTStoreConfig(); uploadToTStore(); - } catch(err) - { + } catch (err) { console.error(err.message); } } @@ -205,20 +207,33 @@ function generateTStoreConfig() { function generateReleaseBody() { const changelog = readFileSync(CHANGELOG_PATH, "utf-8"); - const versionRegExp = new RegExp('\\b[0-9]+\\.[0-9]+(?:\\.[0-9]+)?(?:\\.[0-9]+)?(?=:)\\b', 'g'); + const versionRegExp = new RegExp( + "\\b[0-9]+\\.[0-9]+(?:\\.[0-9]+)?(?:\\.[0-9]+)?(?=:)\\b", + "g" + ); const versions = Array.from(changelog.matchAll(versionRegExp)); const currentVersion = versions[0][0]; - if(pluginInfo.version != currentVersion) - { - throw `CHANGELOG.md latest version (${currentVersion}) does not match version.json (${pluginInfo.version}) !`; - } + if (pluginInfo.version != currentVersion) { + throw `CHANGELOG.md latest version (${currentVersion}) does not match version.json (${pluginInfo.version}) !`; + } - const body = changelog.substr(versions[0].index + versions[0][0].length + 1, versions[1].index - versions[0].index - versions[0][0].length - versions[1][0].length ).trim(); + const body = changelog + .substr( + versions[0].index + versions[0][0].length + 1, + versions[1].index - + versions[0].index - + versions[0][0].length - + versions[1][0].length + ) + .trim(); - writeFileSync(join(DIST_RELEASE_FOLDER, "BODY.md"), "# Alpha Version " + currentVersion + "\n\n### Changes\n" + body); + writeFileSync( + join(DIST_RELEASE_FOLDER, "BODY.md"), + "# Alpha Version " + currentVersion + "\n\n### Changes\n" + body + ); console.log(body); } @@ -229,9 +244,15 @@ async function createTStoreArchive() { async function createGHArchive() { // Ensure contents are within subfolder in zip - await move(DIST_NEBULA_FOLDER, join(DIST_FOLDER, "tmp", NEBULA_RELEASE_FOLDER_NAME)); + await move( + DIST_NEBULA_FOLDER, + join(DIST_FOLDER, "tmp", NEBULA_RELEASE_FOLDER_NAME) + ); await zip(join(DIST_FOLDER, "tmp"), GH_ARCHIVE_PATH); - await move(join(DIST_FOLDER, "tmp", NEBULA_RELEASE_FOLDER_NAME), DIST_NEBULA_FOLDER); + await move( + join(DIST_FOLDER, "tmp", NEBULA_RELEASE_FOLDER_NAME), + DIST_NEBULA_FOLDER + ); await remove(join(DIST_FOLDER, "tmp")); } @@ -240,9 +261,9 @@ function uploadToTStore() { DIST_TSTORE_CLI_EXE_PATH + " publish --config " + DIST_TSTORE_CLI_CONFIG_PATH, - function(err) { - console.error(err); - } + function (err) { + console.error(err); + } ); } diff --git a/.github/workflows/build-winx64.yml b/.github/workflows/build-winx64.yml index c07270656..a549645f4 100644 --- a/.github/workflows/build-winx64.yml +++ b/.github/workflows/build-winx64.yml @@ -15,7 +15,7 @@ jobs: # We *only* want to run this if a collaborator or owner of the repo approves a pull request, or if something is merged into the main branch if: ${{ github.event.ref == 'refs/heads/master' || (github.event.review.state == 'approved' && (github.event.review.author_association == 'COLLABORATOR' || github.event.review.author_association == 'OWNER')) }} - runs-on: dsp-installed + runs-on: windows-latest env: Solution_Name: Nebula.sln @@ -29,7 +29,10 @@ jobs: - name: Clear output directory in DSP files # We use SilentlyContinue here because it errors out if the folder does not exist otherwise - run: rm -R -ErrorAction SilentlyContinue "C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\plugins\Nebula" + run: rm -R -ErrorAction SilentlyContinue "dist\release\nebula" + + - name: Add remote build identifier + run: New-Item -Name .remoteBuild -ItemType File -force # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe @@ -43,8 +46,8 @@ jobs: # Upload it to the run results - name: Upload a Build Artifact - uses: actions/upload-artifact@v2.2.3 + uses: actions/upload-artifact@v2.2.4 with: # Artifact name name: build-artifacts-${{ matrix.configuration }} - path: C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\plugins\Nebula + path: dist\release\nebula diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 3a5a8f7b9..4a7960cf6 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -6,19 +6,14 @@ on: jobs: build: - runs-on: dsp-installed + runs-on: windows-latest env: SOLUTION_NAME: Nebula.sln - PLUGIN_PATH : C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\plugins\ - NEBULA_FOLDER : Nebula\ + NEBULA_FOLDER : dist\\release\\nebula\\ DIST_RELEASE_FOLDER : dist\\release\\ steps: - - name: Set NEBULA_PATH environmental variable - id: nebula-path - run: > - echo "::set-output name=PATH::${{ env.PLUGIN_PATH }}${{ env.NEBULA_FOLDER }}" - name: Checkout uses: actions/checkout@v2 with: @@ -51,7 +46,10 @@ jobs: - name: Clear output directory in DSP files # We use SilentlyContinue here because it errors out if the folder does not exist otherwise - run : rm -R -ErrorAction SilentlyContinue "${{ steps.nebula-path.outputs.PATH }}" + run : rm -R -ErrorAction SilentlyContinue "${{ env.NEBULA_FOLDER }}" + + - name: Add remote build identifier + run: copy /b /Y NUL .remoteBuild # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe diff --git a/Directory.Build.props b/Directory.Build.props index 357516fd9..cbef6976b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,11 +10,9 @@ C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\ $([MSBuild]::EnsureTrailingSlash('$(DSPGameDir)')) - $([MSBuild]::EnsureTrailingSlash('$(SteamDir)')) - $(DSPGameDir)BepInEx\core\ - $(DSPGameDir)DSPGAME_Data\Managed\ $(DSPGameDir)BepInEx\plugins\Nebula\ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)')) + $(PropSheetPath)dist\release\nebula @@ -22,7 +20,7 @@ false true - $(PluginOutputDirectory) + $(PluginOutputDirectory) $(OutputPath) net472 7.3 diff --git a/SharedConfig.targets b/SharedConfig.targets index 4072d9fec..f45029257 100644 --- a/SharedConfig.targets +++ b/SharedConfig.targets @@ -23,5 +23,5 @@ + Condition="!Exists('$(DSPGameDir)') And !Exists('$(PropSheetPath).remoteBuild')" /> \ No newline at end of file