From 85cb2239615d1936288944e7184afb243b081871 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Thu, 22 Aug 2024 18:21:26 -0500 Subject: [PATCH] Updates actions --- .github/workflows/build.yml | 48 ++++++----------------- .github/workflows/release.yml | 74 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d60f125..ea9d9f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,29 +2,12 @@ name: Build project on: push: - tags: - - '*' + branches: + - master workflow_dispatch: jobs: - prepareBuild: - name: Create Release - runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.createRelease.outputs.upload_url }} - steps: - - name: Create Release - id: createRelease - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release v${{ github.ref }} - draft: false - prerelease: true - - buildForAllSupportedPlatforms: + build: name: Build ${{ matrix.projectPath }} for ${{ matrix.targetPlatform }} runs-on: ubuntu-latest needs: prepareBuild @@ -40,22 +23,21 @@ jobs: - win-x64 # Build a Windows 64-bit standalone. - osx-x64 # Build a Linux 64-bit standalone. dotnet: - - '7.x' - - '6.x' + - 8.x steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - + - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: | ${{ matrix.dotnet }} 3.1.x - name: Build - run: dotnet publish ${{ matrix.projectPath }} --configuration Release --runtime ${{ matrix.targetPlatform }} -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishSingleFile=true -p:Version=$(git describe --tags --abbrev=0) --self-contained false --output ./Build/${{ matrix.targetPlatform }} + run: dotnet publish ${{ matrix.projectPath }} --configuration Release --runtime ${{ matrix.targetPlatform }} -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishSingleFile=true -p:Version=$(git describe --tags) --self-contained false --output ./Build/${{ matrix.targetPlatform }} - name: Zip build run: | @@ -63,13 +45,9 @@ jobs: zip -r ../../Blocktest-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip . popd - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 #TODO: Update to a maintained action - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Artifact + uses: actions/upload-artifact@v4 with: - upload_url: ${{ needs.prepareBuild.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./Blocktest-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip - asset_name: ${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip - asset_content_type: application/zip + name: ${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ matrix.dotnet }} + path: ./Blocktest-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip + compression-level: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..40dd135 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,74 @@ +name: Build project + +on: + push: + tags: + - "*" + workflow_dispatch: + +jobs: + prepareBuild: + name: Create Release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.createRelease.outputs.upload_url }} + steps: + - name: Create Release + id: createRelease + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release v${{ github.ref }} + draft: false + prerelease: true + + buildForAllSupportedPlatforms: + name: Build ${{ matrix.projectPath }} for ${{ matrix.targetPlatform }} + runs-on: ubuntu-latest + needs: prepareBuild + strategy: + fail-fast: false + matrix: + projectPath: + - Blocktest + - DedicatedServer + targetPlatform: + - linux-x64 # Build a macOS standalone (Intel 64-bit). + - win-x86 # Build a Windows 32-bit standalone. + - win-x64 # Build a Windows 64-bit standalone. + - osx-x64 # Build a Linux 64-bit standalone. + dotnet: + - 8.x + steps: + - uses: actions/checkout@v3 + with: + lfs: true + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + ${{ matrix.dotnet }} + 3.1.x + + - name: Build + run: dotnet publish ${{ matrix.projectPath }} --configuration Release --runtime ${{ matrix.targetPlatform }} -p:PublishReadyToRun=false -p:TieredCompilation=false -p:PublishSingleFile=true -p:Version=$(git describe --tags --abbrev=0) --self-contained false --output ./Build/${{ matrix.targetPlatform }} + + - name: Zip build + run: | + pushd Build/${{ matrix.targetPlatform }} + zip -r ../../Blocktest-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip . + popd + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 #TODO: Update to a maintained action + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.prepareBuild.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Blocktest-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip + asset_name: ${{ matrix.projectPath }}-${{ matrix.targetPlatform }}-${{ matrix.dotnet }}.zip + asset_content_type: application/zip