This repository has been archived on 2026-08-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
biss f61e298871
Build and Release / Publish Windows, Linux and macOS (push) Successful in 3m7s
Migrate desktop app to Avalonia and publish cross-platform releases
2026-07-19 08:51:41 +08:00

100 lines
2.6 KiB
YAML

name: Build and Release
on:
push:
tags:
- "v*"
permissions:
code: read
releases: write
jobs:
release:
name: Publish Windows, Linux and macOS
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Read release metadata
id: metadata
shell: bash
env:
TAG_NAME: ${{ gitea.ref_name }}
run: |
set -euo pipefail
version="${TAG_NAME#v}"
if [[ -z "${version}" ]]; then
echo "The release tag must contain a version, for example v1.0.0."
exit 1
fi
prerelease=false
if [[ "${version}" == *-* ]]; then
prerelease=true
fi
echo "version=${version}" >> "${GITEA_OUTPUT}"
echo "prerelease=${prerelease}" >> "${GITEA_OUTPUT}"
- name: Publish all desktop platforms
shell: bash
env:
TAG_NAME: ${{ gitea.ref_name }}
VERSION: ${{ steps.metadata.outputs.version }}
run: |
set -euo pipefail
runtimes=(win-x64 linux-x64 osx-x64)
mkdir -p ./dist
for runtime in "${runtimes[@]}"; do
publish_dir="./publish/${runtime}"
dotnet publish ./kcsj.csproj \
--configuration Release \
--runtime "${runtime}" \
--self-contained true \
--output "${publish_dir}" \
-p:PublishSingleFile=true \
-p:EnableCompressionInSingleFile=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
-p:DebugType=None \
-p:Version="${VERSION}"
if [[ "${runtime}" == "win-x64" ]]; then
cp "${publish_dir}/kcsj.exe" "./dist/kcsj-${TAG_NAME}-${runtime}.exe"
else
tar -czf "./dist/kcsj-${TAG_NAME}-${runtime}.tar.gz" \
-C "${publish_dir}" .
fi
done
(
cd ./dist
sha256sum kcsj-* > SHA256SUMS.txt
)
# Gitea's release action is written in Go and is compiled by the runner.
- name: Set up Go for the release action
uses: actions/setup-go@v5
with:
go-version: stable
- name: Create Gitea release
uses: https://gitea.com/actions/release-action@main
with:
title: ${{ gitea.ref_name }}
pre_release: ${{ steps.metadata.outputs.prerelease }}
files: |-
dist/*
api_key: ${{ secrets.GITEA_TOKEN }}