Skip to content

Commit

Permalink
Create main.yml
Browse files Browse the repository at this point in the history
GitHub Actions setup
  • Loading branch information
HenryMarkle authored May 23, 2024
1 parent 3de6e2f commit d5cb654
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Build and Publish

on:
push:
branches:
- main

jobs:
build-linux:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release

- name: Publish
run: dotnet publish --configuration Release --output ./output

- name: Copy assets folder to output directory
run: cp -r ./assets ./output/assets

- name: Archive output
uses: actions/upload-artifact@v2
with:
name: linux-binaries
path: ./output

- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.run_number }}
release_name: Release v${{ github.run_number }}
draft: false
prerelease: false

- name: Upload Linux Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./output
asset_name: linux-output.zip
asset_content_type: application/zip

build-windows:
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release

- name: Publish
run: dotnet publish --configuration Release --output ./output

- name: Copy assets folder to output directory
run: Copy-Item -Recurse -Path ./assets -Destination ./output/assets

- name: Archive output
uses: actions/upload-artifact@v2
with:
name: windows-binaries
path: ./output

- name: Upload Windows Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.build-linux.outputs.create_release.outputs.upload_url }}
asset_path: ./output
asset_name: windows-output.zip
asset_content_type: application/zip

0 comments on commit d5cb654

Please sign in to comment.