Skip to content

ci(publish): add ready-to-run build variants in workflow #58

ci(publish): add ready-to-run build variants in workflow

ci(publish): add ready-to-run build variants in workflow #58

Workflow file for this run

name: publish
env:
ProjectName: KeyAsio.Net
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build:
name: Build and Release
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Restore dependencies
run: |
dotnet restore src/Apps/KeyAsio -r win-x64
- name: Secrets
shell: pwsh
env:
OFFICIAL_PUBLIC_KEY: ${{ secrets.OFFICIAL_PUBLIC_KEY }}
OFFICIAL_PRIVATE_KEY: ${{ secrets.OFFICIAL_PRIVATE_KEY }}
run: |
$secretsContent = 'public partial class Secrets { internal static readonly string Dsn ="${{ secrets.SENTRY_DSN }}"; internal static readonly string OfficialPublicKey = @"' + $env:OFFICIAL_PUBLIC_KEY + '"; }'
Set-Content -Path "src/Common/KeyAsio.Secrets/Secrets.cs" -Value $secretsContent
if ($env:OFFICIAL_PRIVATE_KEY) {
Set-Content -Path "src/Apps/KeyAsio/keyasio_private.key" -Value $env:OFFICIAL_PRIVATE_KEY
}
- name: Publish
run: |
echo ${{ github.ref }}
dotnet publish src/Apps/KeyAsio --no-restore --framework net10.0 --runtime win-x64 --self-contained --configuration Release --output ci-publish-win64 -p:PublishReadyToRun=false
dotnet publish src/Apps/KeyAsio --no-restore --framework net10.0 --runtime win-x64 --self-contained --configuration Release --output ci-publish-win64-r2r -p:PublishReadyToRun=true
dotnet publish src/Apps/KeyAsio --no-restore --framework net10.0 --runtime win-x64 --self-contained false --configuration Release --output ci-publish-win64-fd -p:PublishReadyToRun=false
dotnet publish src/Apps/KeyAsio --no-restore --framework net10.0 --runtime win-x64 --self-contained false --configuration Release --output ci-publish-win64-fd-r2r -p:PublishReadyToRun=true
- name: Confuser
shell: pwsh
run: |
echo '<project outputDir="." baseDir=".\ci-publish-win64" xmlns="http://confuser.codeplex.com"><rule pattern="true" preset="maximum" inherit="false" /><module path="KeyAsio.Secrets.dll" /></project>'>confuse64.crproj
mkdir Confuser -Force
Invoke-WebRequest ${{ secrets.CONFUSER_DLURL }} -OutFile "Confuser/cli.zip"
7z x "Confuser/cli.zip" -oConfuser/
.\Confuser\${{ secrets.CONFUSER_EXE }} -file ".\ci-publish-win64\KeyAsio.Secrets.dll" -targetfile "<AssemblyLocation>\<AssemblyFileName>" -anti_debug 1 -hide_calls 1 -control_flow 1 -flow_level 9 -virtualization 1 -naming stealth
del .\ci-publish-win64\KeyAsio.Secrets.pdb -Force
.\Confuser\${{ secrets.CONFUSER_EXE }} -file ".\ci-publish-win64-r2r\KeyAsio.Secrets.dll" -targetfile "<AssemblyLocation>\<AssemblyFileName>" -anti_debug 1 -hide_calls 1 -control_flow 1 -flow_level 9 -virtualization 1 -naming stealth
del .\ci-publish-win64-r2r\KeyAsio.Secrets.pdb -Force
.\Confuser\${{ secrets.CONFUSER_EXE }} -file ".\ci-publish-win64-fd\KeyAsio.Secrets.dll" -targetfile "<AssemblyLocation>\<AssemblyFileName>" -anti_debug 1 -hide_calls 1 -control_flow 1 -flow_level 9 -virtualization 1 -naming stealth
del .\ci-publish-win64-fd\KeyAsio.Secrets.pdb -Force
.\Confuser\${{ secrets.CONFUSER_EXE }} -file ".\ci-publish-win64-fd-r2r\KeyAsio.Secrets.dll" -targetfile "<AssemblyLocation>\<AssemblyFileName>" -anti_debug 1 -hide_calls 1 -control_flow 1 -flow_level 9 -virtualization 1 -naming stealth
del .\ci-publish-win64-fd-r2r\KeyAsio.Secrets.pdb -Force
- name: Set dll path
shell: pwsh
run: |
copy .\src\Apps\KeyAsio\DotNetDllPathPatcher.ps1 .\DotNetDllPathPatcher.ps1
.\src\Apps\KeyAsio\afterbuild.ps1 .\ci-publish-win64\KeyASIO.exe
.\src\Apps\KeyAsio\afterbuild.ps1 .\ci-publish-win64-r2r\KeyASIO.exe
.\src\Apps\KeyAsio\afterbuild.ps1 .\ci-publish-win64-fd\KeyASIO.exe
.\src\Apps\KeyAsio\afterbuild.ps1 .\ci-publish-win64-fd-r2r\KeyASIO.exe
- name: Upload Artifacts
if: contains(github.ref_name, 'alpha')
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}-${{ github.ref_name }}-win64
path: ./ci-publish-win64/*
- name: Upload Artifacts (R2R)
if: contains(github.ref_name, 'alpha')
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}-${{ github.ref_name }}-win64-r2r
path: ./ci-publish-win64-r2r/*
- name: Upload Artifacts (FD)
if: contains(github.ref_name, 'alpha')
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent
path: ./ci-publish-win64-fd/*
- name: Upload Artifacts (FD R2R)
if: contains(github.ref_name, 'alpha')
uses: actions/upload-artifact@v4
with:
name: ${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent-r2r
path: ./ci-publish-win64-fd-r2r/*
- name: Pack via 7z
if: ${{ !contains(github.ref_name, 'alpha') }}
run: |
mkdir -p ./ci-pack/
7z a -mx9 -mfb=273 -ms -md=31 -myx=9 -mtm=- -mmt -mmtf -md=1536m -mmf=bt3 -mmc=10000 -mpb=0 -mlc=0 "./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64.7z" "./ci-publish-win64/*" -x!"${{ env.ProjectName }}" -r
7z a -mx9 -mfb=273 -ms -md=31 -myx=9 -mtm=- -mmt -mmtf -md=1536m -mmf=bt3 -mmc=10000 -mpb=0 -mlc=0 "./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-r2r.7z" "./ci-publish-win64-r2r/*" -x!"${{ env.ProjectName }}" -r
7z a -mx9 -mfb=273 -ms -md=31 -myx=9 -mtm=- -mmt -mmtf -md=1536m -mmf=bt3 -mmc=10000 -mpb=0 -mlc=0 "./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent.7z" "./ci-publish-win64-fd/*" -x!"${{ env.ProjectName }}" -r
7z a -mx9 -mfb=273 -ms -md=31 -myx=9 -mtm=- -mmt -mmtf -md=1536m -mmf=bt3 -mmc=10000 -mpb=0 -mlc=0 "./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent-r2r.7z" "./ci-publish-win64-fd-r2r/*" -x!"${{ env.ProjectName }}" -r
- name: Create a new GitHub release if a new tag is pushed
if: ${{ !contains(github.ref_name, 'alpha') }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
body: |
[Forum page](https://osu.ppy.sh/community/forums/topics/1602658)
## Release notes
1. Place holder
name: ${{ env.ProjectName }}-${{ github.ref_name }}
prerelease: true
draft: false
files: |
./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64.7z
./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-r2r.7z
./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent.7z
./ci-pack/${{ env.ProjectName }}-${{ github.ref_name }}-win64-framework-dependent-r2r.7z