Skip to content

Commit

Permalink
Update dotnet workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Aug 18, 2023
1 parent 832b039 commit d49ad1b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,49 @@ on:
pull_request:
branches: [ main ]

permissions:
contents: write

env:
CONFIGURATION: Release
DOTNET_VERSION: 7.0.x

jobs:
dotnet:
name: .NET
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Quill
run: curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b /usr/local/bin
- name: Setup Release
if: github.event_name == 'create' && github.event.ref_type == 'tag'
run: echo "RELEASE_NAME=${GITHUB_REPOSITORY#*/} ${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Restore
run: dotnet restore
- name: Test
run: dotnet test --configuration Release --no-restore --verbosity normal
- name: Publish linux-x64
run: dotnet publish --configuration Release --no-restore --output ./dist/linux-x64 --runtime linux-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
run: dotnet test --configuration "$CONFIGURATION" --no-restore --verbosity normal
- name: Publish linux-arm64
run: dotnet publish --configuration Release --no-restore --output ./dist/linux-arm64 --runtime linux-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish osx-x64
run: dotnet publish --configuration Release --no-restore --output ./dist/osx-x64 --runtime osx-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime linux-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish linux-x64
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime linux-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish osx-arm64
run: dotnet publish --configuration Release --no-restore --output ./dist/osx-arm64 --runtime osx-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish win-x64
run: dotnet publish --configuration Release --no-restore --output ./dist/win-x64 --runtime win-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime osx-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish osx-x64
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime osx-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish win-arm64
run: dotnet publish --configuration Release --no-restore --output ./dist/win-arm64 --runtime win-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Archive Binaries
if: github.event_name == 'create' && github.event.ref_type == 'tag'
run: |
cd $GITHUB_WORKSPACE/dist/linux-x64 && zip -mr ../${GITHUB_REPOSITORY#*/}-linux-x64.zip .
cd $GITHUB_WORKSPACE/dist/linux-arm64 && zip -mr ../${GITHUB_REPOSITORY#*/}-linux-arm64.zip .
cd $GITHUB_WORKSPACE/dist/osx-x64 && zip -mr ../${GITHUB_REPOSITORY#*/}-osx-x64.zip .
cd $GITHUB_WORKSPACE/dist/osx-arm64 && zip -mr ../${GITHUB_REPOSITORY#*/}-osx-arm64.zip .
cd $GITHUB_WORKSPACE/dist/win-x64 && zip -mr ../${GITHUB_REPOSITORY#*/}-win-x64.zip .
cd $GITHUB_WORKSPACE/dist/win-arm64 && zip -mr ../${GITHUB_REPOSITORY#*/}-win-arm64.zip .
- name: Setup Release
if: github.event_name == 'create' && github.event.ref_type == 'tag'
run: echo "release_name=${GITHUB_REPOSITORY#*/} ${GITHUB_REF_NAME}" >> $GITHUB_ENV
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime win-arm64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Publish win-x64
run: dotnet publish --configuration "$CONFIGURATION" --no-restore --runtime win-x64 --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true /p:SuppressTrimAnalysisWarnings=true /p:TrimMode=partial
- name: Release
if: github.event_name == 'create' && github.event.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
files: ./dist/*
generate_release_notes: true
name: ${{ env.release_name }}
name: ${{ env.RELEASE_NAME }}
20 changes: 20 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<Target Name="SignMacOS"
Condition="'$(IsPublishable)' == 'true' and $([MSBuild]::IsOSPlatform(`Linux`)) and Exists('/usr/local/bin/quill') and ($(RuntimeIdentifier.StartsWith('osx')) or $(AppHostRuntimeIdentifier.StartsWith('osx')))"
AfterTargets="Publish">
<Message Importance="high" Text="Signing: $(PublishedSingleFileName)"/>
<Exec Command="quill sign &quot;$(PublishedSingleFilePath)&quot;"/>
</Target>

<Target Name="Archive"
Condition="'$(IsPublishable)' == 'true' and '$(CI)' == 'true'"
AfterTargets="Publish">
<PropertyGroup>
<ArchiveDir>$([System.IO.Path]::Combine($(SolutionDir), "dist"))</ArchiveDir>
<ArchiveName>$(ProjectName.Substring($([MSBuild]::Add($(ProjectName.IndexOf('.')), 1))))-$(RuntimeIdentifier)</ArchiveName>
<ArchivePath>$([System.IO.Path]::Combine($(ArchiveDir), "$(ArchiveName).zip"))</ArchivePath>
</PropertyGroup>
<MakeDir Directories="$(ArchiveDir)"/>
<ZipDirectory DestinationFile="$(ArchivePath)" SourceDirectory="$(ProjectDir)$(PublishDir)"/>
</Target>
</Project>

0 comments on commit d49ad1b

Please sign in to comment.