mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
260 lines
7.0 KiB
YAML
260 lines
7.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Release tag'
|
|
required: true
|
|
type: string
|
|
is_prerelease:
|
|
description: 'Pre-release'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
DOTNET_VERSION: '10.0.x'
|
|
Solution_Name: LanMontainDesktop.sln
|
|
|
|
jobs:
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
tag: ${{ steps.version.outputs.tag }}
|
|
|
|
steps:
|
|
- name: Get release info
|
|
id: version
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "push" ]]; then
|
|
TAG=${GITHUB_REF#refs/tags/}
|
|
else
|
|
TAG=${{ github.event.inputs.tag }}
|
|
fi
|
|
VERSION=${TAG#v}
|
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
build-windows:
|
|
needs: prepare
|
|
runs-on: windows-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x64, x86]
|
|
name: Build_Windows_${{ matrix.arch }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Restore
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build -c Release --no-restore -v minimal
|
|
|
|
- name: Publish
|
|
run: |
|
|
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj `
|
|
-c Release `
|
|
-o ./publish/windows-${{ matrix.arch }} `
|
|
--self-contained `
|
|
-r win-${{ matrix.arch }} `
|
|
-p:PublishSingleFile=true `
|
|
-p:DebugType=none
|
|
shell: pwsh
|
|
|
|
- name: Package
|
|
run: |
|
|
$version = "${{ needs.prepare.outputs.version }}"
|
|
$arch = "${{ matrix.arch }}"
|
|
$source = "publish/windows-$arch"
|
|
$package = "LanMontainDesktop-$version-win-$arch"
|
|
|
|
New-Item -ItemType Directory -Path "$package" -Force | Out-Null
|
|
Copy-Item -Path "$source/*" -Destination "$package" -Recurse -Force
|
|
Compress-Archive -Path "$package" -DestinationPath "$package.zip" -Force
|
|
|
|
Write-Host "Created: $package.zip"
|
|
shell: pwsh
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-windows-${{ matrix.arch }}
|
|
path: LanMontainDesktop-*.zip
|
|
retention-days: 30
|
|
|
|
build-linux:
|
|
needs: prepare
|
|
runs-on: ubuntu-latest
|
|
name: Build_Linux
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libfontconfig1 libfreetype6 \
|
|
libx11-6 libxrandr2 libxinerama1 \
|
|
libxi6 libxcursor1 libxext6 \
|
|
libxrender1 libxkbcommon-x11-0
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Restore
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build -c Release --no-restore -v minimal
|
|
|
|
- name: Publish
|
|
run: |
|
|
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj \
|
|
-c Release \
|
|
-o ./publish/linux-x64 \
|
|
--self-contained \
|
|
-r linux-x64 \
|
|
-p:PublishSingleFile=true \
|
|
-p:DebugType=none
|
|
|
|
- name: Package
|
|
run: |
|
|
version="${{ needs.prepare.outputs.version }}"
|
|
source="publish/linux-x64"
|
|
package="LanMontainDesktop-$version-linux-x64"
|
|
|
|
mkdir -p "$package"
|
|
cp -r "$source"/* "$package/"
|
|
tar -czf "$package.tar.gz" "$package"
|
|
|
|
echo "Created: $package.tar.gz"
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-linux
|
|
path: LanMontainDesktop-*.tar.gz
|
|
retention-days: 30
|
|
|
|
build-macos:
|
|
needs: prepare
|
|
runs-on: macos-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x64, arm64]
|
|
name: Build_macOS_${{ matrix.arch }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
|
|
|
- name: Restore
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build -c Release --no-restore -v minimal
|
|
|
|
- name: Publish
|
|
run: |
|
|
dotnet publish LanMontainDesktop/LanMontainDesktop.csproj \
|
|
-c Release \
|
|
-o ./publish/macos-${{ matrix.arch }} \
|
|
--self-contained \
|
|
-r osx-${{ matrix.arch }} \
|
|
-p:PublishSingleFile=true \
|
|
-p:DebugType=none
|
|
|
|
- name: Package
|
|
run: |
|
|
version="${{ needs.prepare.outputs.version }}"
|
|
arch="${{ matrix.arch }}"
|
|
source="publish/macos-$arch"
|
|
package="LanMontainDesktop-$version-macos-$arch"
|
|
|
|
mkdir -p "$package"
|
|
cp -r "$source"/* "$package/"
|
|
tar -czf "$package.tar.gz" "$package"
|
|
|
|
echo "Created: $package.tar.gz"
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: release-macos-${{ matrix.arch }}
|
|
path: LanMontainDesktop-*.tar.gz
|
|
retention-days: 30
|
|
|
|
github-release:
|
|
needs: [ prepare, build-windows, build-linux, build-macos ]
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
pattern: release-*
|
|
|
|
- name: Create Release
|
|
uses: ncipollo/release-action@v1
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
draft: false
|
|
prerelease: ${{ github.event.inputs.is_prerelease == 'true' }}
|
|
artifacts: artifacts/**/*
|
|
body: |
|
|
## Release ${{ needs.prepare.outputs.version }}
|
|
|
|
### Downloads
|
|
|
|
**Windows:**
|
|
- win-x64 (64-bit)
|
|
- win-x86 (32-bit)
|
|
|
|
**Linux:**
|
|
- linux-x64
|
|
|
|
**macOS:**
|
|
- macos-x64 (Intel)
|
|
- macos-arm64 (Apple Silicon)
|
|
|
|
See commits for changes.
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|