From 1c5362fd740c5575d8d6fa0c80779effea21b327 Mon Sep 17 00:00:00 2001 From: luizzeroxis Date: Tue, 26 Nov 2024 22:11:09 -0300 Subject: [PATCH] GitHub actions update --- .github/dependabot.yaml | 20 --- .github/workflows/build-master.yml | 12 ++ .github/workflows/build.yml | 42 +++++ .github/workflows/pr_artifacts.yml | 77 --------- .github/workflows/publish_cli.yml | 50 ------ .github/workflows/publish_gui.yml | 49 ------ .github/workflows/publish_gui_nightly.yml | 181 ---------------------- .github/workflows/publish_gui_release.yml | 53 ------- .github/workflows/publish_pr.yml | 94 ----------- 9 files changed, 54 insertions(+), 524 deletions(-) delete mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/build-master.yml create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/pr_artifacts.yml delete mode 100644 .github/workflows/publish_cli.yml delete mode 100644 .github/workflows/publish_gui.yml delete mode 100644 .github/workflows/publish_gui_nightly.yml delete mode 100644 .github/workflows/publish_gui_release.yml delete mode 100644 .github/workflows/publish_pr.yml diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml deleted file mode 100644 index 2d1a6b3e9..000000000 --- a/.github/dependabot.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# To get started with Dependabot version updates, you'll need to specify which -# package ecosystems to update and where the package manifests are located. -# Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "nuget" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "daily" - labels: - - "dependencies" - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - labels: - - "dependencies" diff --git a/.github/workflows/build-master.yml b/.github/workflows/build-master.yml new file mode 100644 index 000000000..6c6f0b288 --- /dev/null +++ b/.github/workflows/build-master.yml @@ -0,0 +1,12 @@ +name: Build master + +on: + push: + branches: [ master ] + workflow_dispatch: + +jobs: + build_master: + uses: ./.github/workflows/build.yml + with: + debug: true \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..5cc95f574 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Build + +on: + workflow_call: + inputs: + debug: + description: 'If true, build with Debug configuration, otherwise build with Release configuration' + type: boolean + default: false + +env: + CONFIGURATION: ${{ inputs.debug && 'Debug' || 'Release' }} + +jobs: + build_gui: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore -r win-x64 + - name: Publish UndertaleModTool + run: dotnet publish UndertaleModTool --no-restore -c ${{ env.CONFIGURATION }} --self-contained true -p:PublishSingleFile=true -p:DebugType=embedded --output ./publish/UndertaleModTool + - name: Publish UndertaleModToolUpdater + run: dotnet publish UndertaleModToolUpdater --no-restore -c ${{ env.CONFIGURATION }} --self-contained true -p:PublishSingleFile=true -p:DebugType=embedded --output ./publish/UndertaleModTool/Updater + - name: Copy external files + run: | + cp ./README.md ./publish/UndertaleModTool + cp ./SCRIPTS.md ./publish/UndertaleModTool + cp ./LICENSE.txt ./publish/UndertaleModTool + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: UndertaleModTool-${{ env.CONFIGURATION }} + path: ./publish/UndertaleModTool \ No newline at end of file diff --git a/.github/workflows/pr_artifacts.yml b/.github/workflows/pr_artifacts.yml deleted file mode 100644 index f2fc1926c..000000000 --- a/.github/workflows/pr_artifacts.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Upload PR Artifacts -on: - workflow_run: - workflows: - - Publish PR - types: - - completed -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }}-artifacts - cancel-in-progress: true -jobs: - pr_Comment: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v6 - with: - script: | - const {owner, repo} = context.repo; - const run_id = ${{github.event.workflow_run.id}}; - const pull_head_sha = "${{github.event.workflow_run.head_sha}}"; - - // hack to get PR number - iterate through all PRs - const issue_number = await (async () => - { - const pulls = await github.rest.pulls.list({owner, repo}); - for await (const {data} of github.paginate.iterator(pulls)) - { - for (const pull of data) - { - if (pull.head.sha === pull_head_sha) - return pull.number; - } - } - })(); - if (!issue_number) - return core.error("No pull request found"); - - - core.info("Using pull request " + issue_number); - - const {data: {artifacts}} = await github.rest.actions.listWorkflowRunArtifacts({owner, repo, run_id}); - if (!artifacts.length) - return core.error("No artifacts found"); - - core.info("Artifacts found"); - - let body = "Download the artifacts for this pull request here:\n"; - let gui_part = "\nGUI:\n"; - let cli_part = "\nCLI:\n"; - for (const artifact of artifacts) - { - if (artifact.name.includes("GUI-")) - { - gui_part += `\n* [${artifact.name}](https://nightly.link/${owner}/${repo}/actions/artifacts/${artifact.id}.zip)`; - } - else if(artifact.name.includes("CLI-")) - { - cli_part += `\n* [${artifact.name}](https://nightly.link/${owner}/${repo}/actions/artifacts/${artifact.id}.zip)`; - } - } - gui_part += "\n"; - cli_part += "\n"; - body += gui_part + cli_part; - - const {data: comments} = await github.rest.issues.listComments({repo, owner, issue_number}); - const doesCommentExist = comments.find((c) => c.user.login === "github-actions[bot]"); - if (doesCommentExist) - { - core.info("Updating existing comment on PR " + issue_number); - await github.rest.issues.updateComment({repo, owner, comment_id: doesCommentExist.id, body}); - } - else - { - core.info("Creating new comment on PR " + issue_number); - await github.rest.issues.createComment({repo, owner, issue_number, body}); - } diff --git a/.github/workflows/publish_cli.yml b/.github/workflows/publish_cli.yml deleted file mode 100644 index 49c173b40..000000000 --- a/.github/workflows/publish_cli.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Publish CLI - -on: - #push: - # branches: [ master ] - workflow_dispatch: - -jobs: - publish_cli: - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - configuration: [Debug] - bundled: [true, false] - include: - - os: ubuntu-latest - rid: linux-x64 - - os: macOS-latest - rid: osx-x64 - - os: windows-latest - rid: win-x64 - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore UndertaleModCli - - name: Build - run: dotnet build UndertaleModCli --no-restore - - name: Publish ${{ matrix.os }} CLI - run: dotnet publish UndertaleModCli -c ${{ matrix.configuration }} -r ${{ matrix.rid }} --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output CLI-${{ matrix.os }} - - name: Copy external files - run: | - cp ./README.md ./CLI-${{ matrix.os }}/ - cp ./LICENSE.txt ./CLI-${{ matrix.os }}/ - cp -r ./UndertaleModLib/GameSpecificData/ ./CLI-${{ matrix.os }}/GameSpecificData/ - - name: Upload ${{ matrix.os }} CLI - uses: actions/upload-artifact@v4 - with: - name: CLI-${{ matrix.os }}-isBundled-${{ matrix.bundled }} - path: CLI-${{ matrix.os }} diff --git a/.github/workflows/publish_gui.yml b/.github/workflows/publish_gui.yml deleted file mode 100644 index 1caca28f6..000000000 --- a/.github/workflows/publish_gui.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Publish GUI - -on: - #push: - # branches: [ master ] - workflow_dispatch: - -jobs: - publish_gui: - - strategy: - fail-fast: false - matrix: - os: [windows-latest] - configuration: [Debug] - bundled: [true, false] - singlefile: [true, false] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: | - dotnet build UndertaleModTool --no-restore - dotnet build UndertaleModToolUpdater --no-restore - - name: Publish ${{ matrix.os }} GUI - run: | - dotnet publish UndertaleModTool -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=${{ matrix.singlefile }} -p:DebugType=embedded --output ${{ matrix.os }} - dotnet publish UndertaleModToolUpdater -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output ${{ matrix.os }}/Updater - - name: Copy external files - run: | - cp ./README.md ./${{ matrix.os }} - cp ./SCRIPTS.md ./${{ matrix.os }} - cp ./LICENSE.txt ./${{ matrix.os }} - cp -r ./UndertaleModLib/GameSpecificData/ ./${{ matrix.os }}/GameSpecificData/ - - name: Upload ${{ matrix.os }} GUI - uses: actions/upload-artifact@v4 - with: - name: GUI-${{ matrix.os }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }} - path: ${{ matrix.os }} diff --git a/.github/workflows/publish_gui_nightly.yml b/.github/workflows/publish_gui_nightly.yml deleted file mode 100644 index 02aa2bbec..000000000 --- a/.github/workflows/publish_gui_nightly.yml +++ /dev/null @@ -1,181 +0,0 @@ -name: Publish continuous release of UndertaleModTool - -on: - push: - branches: [ master ] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -jobs: - build_gui: - - strategy: - fail-fast: false - matrix: - os: [windows-latest] - configuration: [Debug] - bundled: [true] - singlefile: [true, false] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: | - dotnet build UndertaleModTool --no-restore - dotnet build UndertaleModToolUpdater --no-restore - - name: Publish ${{ matrix.os }} GUI - run: | - dotnet publish UndertaleModTool -c ${{ matrix.configuration }} -r win-x64 -p:DefineConstants="SHOW_COMMIT_HASH" --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=${{ matrix.singlefile }} -p:DebugType=embedded --output ${{ matrix.os }} - dotnet publish UndertaleModToolUpdater -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output ${{ matrix.os }}/Updater - - name: Copy external files - run: | - cp ./README.md ./${{ matrix.os }} - cp ./SCRIPTS.md ./${{ matrix.os }} - cp ./LICENSE.txt ./${{ matrix.os }} - cp -r ./UndertaleModLib/GameSpecificData/ ./${{ matrix.os }}/GameSpecificData/ - - name: Create zip for nightly release Windows GUI - run: | - 7z a -tzip GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }}.zip ./${{ matrix.os }}/* -mx0 - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }} - path: GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }}.zip - - build_cli: - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - configuration: [Debug] - bundled: [true] - include: - - os: ubuntu-latest - rid: linux-x64 - - os: macOS-latest - rid: osx-x64 - - os: windows-latest - rid: win-x64 - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore UndertaleModCli - - name: Build - run: dotnet build UndertaleModCli --no-restore - - name: Publish ${{ matrix.os }} CLI - run: dotnet publish UndertaleModCli -c ${{ matrix.configuration }} -r ${{ matrix.rid }} --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output CLI-${{ matrix.os }} - - name: Copy external files - run: | - cp ./README.md ./CLI-${{ matrix.os }}/ - cp ./LICENSE.txt ./CLI-${{ matrix.os }}/ - cp -r ./UndertaleModLib/GameSpecificData/ ./CLI-${{ matrix.os }}/GameSpecificData/ - - name: Create zip for nightly release CLI - run: | - 7z a -tzip CLI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}.zip ./CLI-${{ matrix.os }}/* -mx0 - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: CLI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }} - path: CLI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}.zip - - upload: - - needs: [build_gui, build_cli] - runs-on: ubuntu-latest - steps: - - name: Download artifacts - uses: actions/download-artifact@v4 - - name: Delete tag and release - uses: dev-drprasad/delete-tag-and-release@v1.1 - with: - delete_release: true # default: false - tag_name: bleeding-edge # tag name to delete - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Release - uses: softprops/action-gh-release@v2 - with: - tag_name: bleeding-edge - name: Bleeding Edge - prerelease: true - fail_on_unmatched_files: true - files: | - */* - body: | - This is an automatically updating **bleeding edge** build of UndertaleModTool. There *will* be bugs! If you encounter any, please make an issue on GitHub or join the Underminers Discord for more help! - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check and fix the release - uses: actions/github-script@v7 - with: - script: | - // Wait 10 seconds - await new Promise(r => setTimeout(r, 10000)); - - const {owner, repo} = context.repo; - const listReleasesResponse = await github.rest.repos.listReleases({ - owner, - repo - }); - - if (listReleasesResponse.status !== 200) - throw new Error("Error listing releases"); - - let release_id; - for (let release of listReleasesResponse.data) { - if (release.tag_name !== "bleeding-edge") - continue; - - console.log(release); - - if (!release.draft) { - console.log("Found published bleeding edge release - no need to do anything."); - return; - } - - if (release_id == undefined) - release_id = release.id; - } - - if (release_id == undefined) - throw new Error("The bleeding edge release was not found."); - - console.warn("Found the bleeding edge release that is draft.\nTrying to publish..."); - - try { - await github.rest.repos.updateRelease({owner, repo, release_id, draft: false}); - } - catch (err) { - if ('status' in err && err.status == 422) { - console.log('A non-draft release already exists?'); - console.error(err); - return; - } - else - throw err; - } - - console.log("The draft release was published successfully."); diff --git a/.github/workflows/publish_gui_release.yml b/.github/workflows/publish_gui_release.yml deleted file mode 100644 index 20a5101cb..000000000 --- a/.github/workflows/publish_gui_release.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Publish stable release of UndertaleModTool GUI - -on: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: true - -jobs: - build_gui: - - strategy: - fail-fast: false - matrix: - os: [windows-latest] - configuration: [Release] - bundled: [true] - singlefile: [true, false] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: | - dotnet build UndertaleModTool --no-restore - - name: Publish ${{ matrix.os }} GUI - run: | - dotnet publish UndertaleModTool -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=${{ matrix.singlefile }} -p:DebugType=embedded --output ${{ matrix.os }} - - name: Copy external files - run: | - cp ./README.md ./${{ matrix.os }} - cp ./SCRIPTS.md ./${{ matrix.os }} - cp ./LICENSE.txt ./${{ matrix.os }} - cp -r ./UndertaleModLib/GameSpecificData/ ./${{ matrix.os }}/GameSpecificData/ - - name: Create zip for stable release Windows GUI - run: | - 7z a -tzip GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }}.zip ./${{ matrix.os }}/* -mx0 - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }} - path: GUI-${{ matrix.os }}-${{ matrix.configuration }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }}.zip - diff --git a/.github/workflows/publish_pr.yml b/.github/workflows/publish_pr.yml deleted file mode 100644 index bf5517d5c..000000000 --- a/.github/workflows/publish_pr.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Publish PR -on: - pull_request: - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -jobs: - build_gui: - - strategy: - fail-fast: false - matrix: - os: [windows-latest] - configuration: [Debug] - bundled: [false] - singlefile: [true, false] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: | - dotnet build UndertaleModTool --no-restore - dotnet build UndertaleModToolUpdater --no-restore - - name: Publish ${{ matrix.os }} GUI - run: | - dotnet publish UndertaleModTool -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=${{ matrix.singlefile }} -p:DebugType=embedded --output ${{ matrix.os }} - dotnet publish UndertaleModToolUpdater -c ${{ matrix.configuration }} -r win-x64 --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output ${{ matrix.os }}/Updater - - name: Copy external files - run: | - cp ./README.md ./${{ matrix.os }} - cp ./SCRIPTS.md ./${{ matrix.os }} - cp ./LICENSE.txt ./${{ matrix.os }} - cp -r ./UndertaleModLib/GameSpecificData/ ./${{ matrix.os }}/GameSpecificData/ - - name: Upload ${{ matrix.os }} GUI - uses: actions/upload-artifact@v4 - with: - name: GUI-${{ matrix.os }}-isBundled-${{ matrix.bundled }}-isSingleFile-${{ matrix.singlefile }} - path: ${{ matrix.os }} - - publish_cli: - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] - configuration: [Debug] - bundled: [false] - include: - - os: ubuntu-latest - rid: linux-x64 - - os: macOS-latest - rid: osx-x64 - - os: windows-latest - rid: win-x64 - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - run: dotnet restore UndertaleModCli - - name: Build - run: dotnet build UndertaleModCli --no-restore - - name: Publish ${{ matrix.os }} CLI - run: dotnet publish UndertaleModCli -c ${{ matrix.configuration }} -r ${{ matrix.rid }} --self-contained ${{ matrix.bundled }} -p:PublishSingleFile=false --output CLI-${{ matrix.os }} - - name: Copy external files - run: | - cp ./README.md ./CLI-${{ matrix.os }}/ - cp ./LICENSE.txt ./CLI-${{ matrix.os }}/ - cp -r ./UndertaleModLib/GameSpecificData/ ./CLI-${{ matrix.os }}/GameSpecificData/ - - name: Upload ${{ matrix.os }} CLI - uses: actions/upload-artifact@v4 - with: - name: CLI-${{ matrix.os }}-isBundled-${{ matrix.bundled }} - path: CLI-${{ matrix.os }}