Build & Publish Release #17
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 & Publish Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
rid: linux-x64 | |
- os: windows-latest | |
rid: win-x64 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Publish single-file executable | |
run: dotnet publish SlipperyPete.sln \ | |
--configuration Release \ | |
--runtime ${{ matrix.rid }} \ | |
--self-contained true \ | |
/p:PublishSingleFile=true \ | |
/p:PublishTrimmed=true \ | |
--output artifacts/${{ matrix.rid }} | |
- name: Remove PDB files | |
run: | | |
if [[ "${{ runner.os }}" == "Linux" ]]; then | |
find artifacts/${{ matrix.rid }} -type f -name '*.pdb' -delete | |
else | |
Remove-Item artifacts\${{ matrix.rid }}\*.pdb -Force | |
fi | |
- name: Zip artifact | |
run: | | |
cd artifacts | |
if [[ "${{ runner.os }}" == "Linux" ]]; then | |
zip -r ${{ matrix.rid }}.zip ${{ matrix.rid }} | |
else | |
Compress-Archive -Path ${{ matrix.rid }}\* -DestinationPath ${{ matrix.rid }}.zip | |
fi | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.rid }} | |
path: artifacts/${{ matrix.rid }}.zip | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Download Linux artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: linux-x64 | |
- name: Download Windows artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: win-x64 | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
body_path: CHANGELOG.md | |
draft: false | |
prerelease: false | |
- name: Upload Linux Release Asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: linux-x64.zip | |
asset_name: linux-x64.zip | |
asset_content_type: application/zip | |
- name: Upload Windows Release Asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: win-x64.zip | |
asset_name: win-x64.zip | |
asset_content_type: application/zip |