Skip to content

Build and Release

Build and Release #2

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install dependencies
run: dotnet restore
- name: Publish application
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
echo "PUBLISHING FOR LINUX"
dotnet publish -c Release -r linux-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
else
echo "PUBLISHING FOR WINDOWS"
dotnet publish -c Release -r win-x64 /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
fi
- name: Create ZIP file
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
zip -r --junk-paths FikaServerTools_${{ github.ref_name }}-linux64.zip ./bin/Release/net8.0/linux-x64/publish/
else
zip -r --junk-paths FikaServerTools_${{ github.ref_name }}-windows64.zip ./bin/Release/net8.0/win-x64/publish/
fi
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: FikaServerTools_${{ matrix.os }}_${{ github.ref_name }}
path: FikaServerTools_${{ github.ref_name }}-*.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts (Linux)
uses: actions/download-artifact@v4
with:
name: FikaServerTools_ubuntu-latest_${{ github.ref_name }}
path: ./dist/linux
- name: Download artifacts (Windows)
uses: actions/download-artifact@v4
with:
name: FikaServerTools_windows-latest_${{ github.ref_name }}
path: ./dist/windows
- name: Publish pre-release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: "Fika-ServerTools ${{ github.ref_name }}"
prerelease: true
files: |
./dist/linux/FikaServerTools_${{ github.ref_name }}-linux64.zip
./dist/windows/FikaServerTools_${{ github.ref_name }}-windows64.zip