From f6c3602d1e5dcd6d8c5e4d958cf762e4199caa9a Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 5 May 2024 20:05:29 +0200 Subject: [PATCH 1/4] Update build workflow to cache nuget packages --- .github/workflows/CI.yml | 49 +++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0a21f1ae..26a6b7e2 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -2,26 +2,43 @@ name: .NET on: [push, pull_request] +env: + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + nuget-cache-key: nuget-package-cache + jobs: + build: runs-on: windows-latest - + steps: - - uses: actions/checkout@v3 - - - name: Checkout submodules - run: | - git submodule update --init --recursive - - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.1 - - - name: Setup NuGet - uses: NuGet/setup-nuget@v1.0.6 + - uses: actions/checkout@v4 + with: + submodules: recursive - - name: Restore NuGet Packages - run: nuget restore PCK_Studio.sln + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 - - name: Build Solution - run: msbuild PCK_Studio.sln + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 + + - name: Restore NuGet Packages + id: nuget-packages-restore + uses: actions/cache/restore@v4 + with: + path: ${{ env.NUGET_PACKAGES }} + key: ${{ runner.os }}-${{ env.nuget-cache-key }} + + - name: Get NuGet Packages + run: nuget restore PCK_Studio.sln + + - name: Cache NuGet Packages + id: nuget-packages-save + uses: actions/cache/save@v4 + with: + path: ${{ env.NUGET_PACKAGES }} + key: ${{ steps.nuget-packages-restore.outputs.cache-primary-key }} + + - name: Build Solution + run: msbuild PCK_Studio.sln From 0b1e1eb3abf73c4d6773ba7051c555fd0b73e2e0 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Mon, 6 May 2024 18:26:02 +0200 Subject: [PATCH 2/4] Add release workflow --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..c5f3d9db --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Create release + +on: + push: + branches: main + tags: v*.* + +env: + RELEASE_NAME: PCK-Studio + +jobs: + CreateRelease: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 + + - name: Get NuGet Packages + run: nuget restore PCK_Studio.sln + + - name: Build solution + run: "msbuild PCK_Studio.sln -p:Configuration=Release" + + - name: Package binary + run: Compress-Archive -Path ${{ github.workspace }}\PCK-Studio\bin\Release\ -Destination ${{ env.RELEASE_NAME }}.zip + + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ${{ env.RELEASE_NAME }}.zip + \ No newline at end of file From d0f4973627265f1b746fe6d1621d14a72a43b153 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 7 May 2024 18:33:22 +0200 Subject: [PATCH 3/4] Update CI workflow name --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 26a6b7e2..7dd68c5d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -name: .NET +name: CI on: [push, pull_request] From 4a856deca5f26e73c765288195fbb0023ea00657 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 7 May 2024 18:45:57 +0200 Subject: [PATCH 4/4] Fix release workflow running when just pushing to the main branch --- .github/workflows/release.yml | 69 +++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5f3d9db..ecfe0c7e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,40 +1,55 @@ name: Create release + + on: push: - branches: main tags: v*.* env: RELEASE_NAME: PCK-Studio - + jobs: + on-main-branch-check: + runs-on: ubuntu-latest + outputs: + on_main: ${{ steps.contains_tag.outputs.retval }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: rickstaa/action-contains-tag@v1 + id: contains_tag + with: + reference: "main" + tag: "${{ github.ref }}" CreateRelease: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive + runs-on: windows-latest + needs: on-main-branch-check + if: ${{ needs.on-main-branch-check.outputs.on_main == 'true' }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup MSBuild + uses: microsoft/setup-msbuild@v2 + + - name: Setup NuGet + uses: NuGet/setup-nuget@v2 - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 - - - name: Setup NuGet - uses: NuGet/setup-nuget@v2 - - - name: Get NuGet Packages - run: nuget restore PCK_Studio.sln - - - name: Build solution - run: "msbuild PCK_Studio.sln -p:Configuration=Release" + - name: Get NuGet Packages + run: nuget restore PCK_Studio.sln + + - name: Build solution + run: "msbuild PCK_Studio.sln -p:Configuration=Release" - - name: Package binary - run: Compress-Archive -Path ${{ github.workspace }}\PCK-Studio\bin\Release\ -Destination ${{ env.RELEASE_NAME }}.zip + - name: Package binary + run: Compress-Archive -Path ${{ github.workspace }}\PCK-Studio\bin\Release\ -Destination ${{ env.RELEASE_NAME }}.zip - - name: Release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - files: ${{ env.RELEASE_NAME }}.zip - \ No newline at end of file + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ${{ env.RELEASE_NAME }}.zip + \ No newline at end of file