diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..f6f5b12 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,105 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' # Trigger on version tags like v1.0.0 + +jobs: + build-linux: + runs-on: ubuntu-latest # GitHub runner for Linux + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build self-contained executable for Linux + run: | + dotnet publish -c Release -r linux-x64 --self-contained -o out/linux-x64/specific-directory + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: app-linux + path: out/linux-x64 + + build-windows: + runs-on: windows-latest # GitHub runner for Windows + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build self-contained executable for Windows + run: | + dotnet publish -c Release -r win-x64 --self-contained -o out/win-x64/specific-directory + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: app-windows + path: out/win-x64 + + release: + needs: [build-linux, build-windows] + runs-on: ubuntu-latest # Release job runs on Linux runner + + steps: + - name: Download Linux Artifacts + uses: actions/download-artifact@v3 + with: + name: app-linux + path: out + + - name: Download Windows Artifacts + uses: actions/download-artifact@v3 + with: + name: app-windows + path: out + + - 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 }} + draft: false + prerelease: false + + - name: Upload Linux Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_path: out/linux-x64/* + asset_name: linux-app-${{ github.ref_name }}.zip + asset_content_type: application/zip + + - name: Upload Windows Release Assets + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-release.outputs.upload_url }} + asset_path: out/win-x64/* + asset_name: windows-app-${{ github.ref_name }}.zip + asset_content_type: application/zip