Files
Empostor/.github/workflows/ci.yml
T
2026-10-06 18:33:25 +08:00

100 lines
3.5 KiB
YAML

name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install Cake.Tool
run: dotnet tool install --global Cake.Tool
- name: Run Cake Build
run: dotnet cake build.cake --target=Build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: build/
- name: Create Release (tag only)
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: build/*
generate_release_notes: true
publish-nightly:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-output
path: build/
- name: Prepare latest files and manifest
run: |
set -euo pipefail
cd build
VERSION=$(ls Empostor-Server_*_linux-x64.tar.gz | head -1 | sed -E 's/^Empostor-Server_(.*)_linux-x64\.tar\.gz$/\1/')
echo "Version: ${VERSION}"
cp Empostor-Server_*_linux-x64.tar.gz Empostor-Server-latest-linux-x64.tar.gz
cp Empostor-Server_*_linux-arm64.tar.gz Empostor-Server-latest-linux-arm64.tar.gz
cp Empostor-Server_*_win-x64.zip Empostor-Server-latest-win-x64.zip
cp Empostor-Server_*_osx-x64.tar.gz Empostor-Server-latest-osx-x64.tar.gz
{
echo '{'
echo " \"version\": \"${VERSION}\","
echo " \"linux-x64\": { \"file\": \"Empostor-Server-latest-linux-x64.tar.gz\", \"sha256\": \"$(sha256sum Empostor-Server-latest-linux-x64.tar.gz | cut -d' ' -f1)\" },"
echo " \"linux-arm64\": { \"file\": \"Empostor-Server-latest-linux-arm64.tar.gz\", \"sha256\": \"$(sha256sum Empostor-Server-latest-linux-arm64.tar.gz | cut -d' ' -f1)\" },"
echo " \"win-x64\": { \"file\": \"Empostor-Server-latest-win-x64.zip\", \"sha256\": \"$(sha256sum Empostor-Server-latest-win-x64.zip | cut -d' ' -f1)\" },"
echo " \"osx-x64\": { \"file\": \"Empostor-Server-latest-osx-x64.tar.gz\", \"sha256\": \"$(sha256sum Empostor-Server-latest-osx-x64.tar.gz | cut -d' ' -f1)\" }"
echo '}'
} > manifest.json
cat manifest.json
- name: Publish nightly release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
cd build
VERSION=$(ls Empostor-Server_*_linux-x64.tar.gz | head -1 | sed -E 's/^Empostor-Server_(.*)_linux-x64\.tar\.gz$/\1/')
gh release delete nightly -y --cleanup-tag || true
gh release create nightly \
Empostor-Server-latest-linux-x64.tar.gz \
Empostor-Server-latest-linux-arm64.tar.gz \
Empostor-Server-latest-win-x64.zip \
Empostor-Server-latest-osx-x64.tar.gz \
manifest.json \
--title "Nightly build (${VERSION})" \
--prerelease \
--notes "Automated nightly build from ${GITHUB_SHA}" \
--target "${GITHUB_SHA}"