Build and Publish x86/x64 #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish x86/x64 | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build-and-publish: | |
| runs-on: windows-latest | |
| outputs: | |
| VERSION: ${{ steps.setver.outputs.VERSION }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: set env vars | |
| id: setver | |
| shell: pwsh | |
| run: | | |
| $ts = Get-Date -Format yyyyMMddHHmmss | |
| $date = Get-Date -Format "yyyy.MMdd.HHmm" | |
| $buildNumber=(Get-Date).Second | |
| $version = "$date.$buildNumber" | |
| "VERSION=$version" >> $env:GITHUB_ENV | |
| "VERSION=$version" >> $env:GITHUB_OUTPUT | |
| - name: Restore | |
| run: dotnet restore memory/Memory.csproj | |
| shell: pwsh | |
| - name: build | |
| run: | | |
| echo "version is $env:VERSION" | |
| dotnet build memory/Memory.csproj -c Release -r win-x86 --self-contained false -p:AssemblyVersion="$env:VERSION" -p:Version="$env:VERSION" -p:NuGetVersion="$env:VERSION" --output ./build/x86 | |
| dotnet pack memory/Memory.csproj -c Release -p:PackageId=Memory-x86 -p:Version="$env:VERSION" -p:RuntimeIdentifier=win-x86 -p:NoBuild=true -p:OutputPath="$PWD/build/x86" --output ./nupkg/x86 | |
| dotnet nuget push ./nupkg/x86/Memory-x86.$env:VERSION.nupkg --api-key ${{ secrets.TOKEN }} --source "https://nuget.pkg.github.com/erfg12/index.json" --skip-duplicate | |
| dotnet build memory/Memory.csproj -c Release -r win-x64 --self-contained false -p:AssemblyVersion="$env:VERSION" -p:Version="$env:VERSION" -p:NuGetVersion="$env:VERSION" --output ./build/x64 | |
| dotnet pack memory/Memory.csproj -c Release -p:PackageId=Memory-x64 -p:Version="$env:VERSION" -p:RuntimeIdentifier=win-x64 -p:NoBuild=true -p:OutputPath="$PWD/build/x64" --output ./nupkg/x64 | |
| dotnet nuget push ./nupkg/x64/Memory-x64.$env:VERSION.nupkg --api-key ${{ secrets.TOKEN }} --source "https://nuget.pkg.github.com/erfg12/index.json" --skip-duplicate | |
| # Upload artifacts for the release job | |
| - name: Upload x86 artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: x86-dll | |
| path: ./build/x86/Memory.dll | |
| - name: Upload x64 artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: x64-dll | |
| path: ./build/x64/Memory.dll | |
| release: | |
| needs: build-and-publish | |
| runs-on: windows-latest | |
| env: | |
| VERSION: ${{ needs.build-and-publish.outputs.VERSION }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Download x86 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: x86-dll | |
| path: ./artifacts/x86 | |
| - name: Download x64 artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: x64-dll | |
| path: ./artifacts/x64 | |
| - name: Get current directory | |
| id: getdir | |
| shell: pwsh | |
| run: | | |
| $cwd = Get-Location | |
| Write-Host "Current directory is $cwd" | |
| echo "CWD=$cwd" >> $env:GITHUB_OUTPUT | |
| - name: Rename artifacts for release | |
| shell: pwsh | |
| run: | | |
| Copy-Item -Path "artifacts\x86\Memory.dll" -Destination "artifacts\x86\Memory-x86.dll" -Force | |
| Copy-Item -Path "artifacts\x64\Memory.dll" -Destination "artifacts\x64\Memory-x64.dll" -Force | |
| - name: List all artifacts | |
| run: | | |
| Write-Host "All artifacts:" | |
| Get-ChildItem -Path ./artifacts -Recurse | ForEach-Object { Write-Host $_.FullName } | |
| shell: pwsh | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ env.VERSION }} | |
| name: Release v${{ env.VERSION }} | |
| body: | | |
| Automated release for build ${{ env.VERSION }} | |
| ## Packages | |
| - Memory-x86 v${{ env.VERSION }} | |
| - Memory-x64 v${{ env.VERSION }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| artifacts\x86\Memory-x86.dll | |
| artifacts\x64\Memory-x64.dll | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |