Files
Empostor/.github/workflows/ci.yml
T

144 lines
4.8 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}"
docker:
needs: build
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
strategy:
matrix:
arch:
- { docker: linux/amd64, rid: amd64 }
- { docker: linux/arm64, rid: arm64 }
- { docker: linux/arm/v7, rid: arm }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build Docker image (${{ matrix.arch.rid }})
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.arch.docker }}
load: true
tags: empostor-server:${{ matrix.arch.rid }}
build-args: |
VERSIONSUFFIX=docker
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
- name: Export Docker image to tar
run: docker save empostor-server:${{ matrix.arch.rid }} -o empostor-server-docker-${{ matrix.arch.rid }}.tar
- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: empostor-docker-${{ matrix.arch.rid }}
path: empostor-server-docker-${{ matrix.arch.rid }}.tar