Skip to content

Commit

Permalink
Updates actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Aug 22, 2024
1 parent 8211ce3 commit 85cb223
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 35 deletions.
48 changes: 13 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,36 +23,31 @@ 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: |
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 }}
- 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
74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 85cb223

Please sign in to comment.