Merge pull request #433 from Moonlight-Panel/v2_AddedVersioning
V2 added versioning
This commit is contained in:
33
.github/workflows/development-build.yml
vendored
Normal file
33
.github/workflows/development-build.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Development Build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
branches: [ "v2" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login into docker hub
|
||||
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }}
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Moonlight/Dockerfile
|
||||
push: true
|
||||
tags: moonlightpanel/moonlight:dev
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
"BUILD_CHANNEL=${GITHUB_REF#refs/heads/}"
|
||||
"BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}"
|
||||
"BUILD_NAME=devbuild ${date}"
|
||||
"BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}"
|
||||
|
||||
30
.github/workflows/release-build.yml
vendored
Normal file
30
.github/workflows/release-build.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Release Build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login into docker hub
|
||||
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PW }}
|
||||
- name: Build and Push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Moonlight/Dockerfile
|
||||
push: true
|
||||
tags: moonlightpanel/moonlight:latest
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: |
|
||||
"BUILD_CHANNEL=${GITHUB_REF#refs/heads/}"
|
||||
"BUILD_COMMIT_HASH=${git rev-parse --short '$GITHUB_SHA'}"
|
||||
"BUILD_NAME=${{ github.event.release.name }}"
|
||||
"BUILD_VERSION=${git rev-parse --short '$GITHUB_SHA'}"
|
||||
@@ -7,10 +7,50 @@ namespace Moonlight.Core.Services;
|
||||
[Singleton]
|
||||
public class MoonlightService
|
||||
{
|
||||
public readonly string BuildChannel;
|
||||
public readonly string BuildCommitHash;
|
||||
public readonly string BuildName;
|
||||
public readonly string BuildVersion;
|
||||
public readonly bool IsDockerRun;
|
||||
|
||||
public WebApplication Application { get; set; } // Do NOT modify using a plugin
|
||||
|
||||
private readonly DateTime StartTimestamp = DateTime.UtcNow;
|
||||
|
||||
public MoonlightService()
|
||||
{
|
||||
//TODO: Maybe extract to a method
|
||||
|
||||
if (!File.Exists("version"))
|
||||
{
|
||||
BuildChannel = "N/A";
|
||||
BuildCommitHash = "N/A";
|
||||
BuildName = "N/A";
|
||||
BuildVersion = "N/A";
|
||||
IsDockerRun = false;
|
||||
}
|
||||
|
||||
var line = File.ReadAllText("version");
|
||||
var parts = line.Split(";");
|
||||
|
||||
if (parts.Length < 5)
|
||||
{
|
||||
BuildChannel = "N/A";
|
||||
BuildCommitHash = "N/A";
|
||||
BuildName = "N/A";
|
||||
BuildVersion = "N/A";
|
||||
IsDockerRun = false;
|
||||
}
|
||||
|
||||
BuildChannel = parts[0];
|
||||
BuildCommitHash = parts[1];
|
||||
BuildName = parts[2];
|
||||
BuildVersion = parts[3];
|
||||
IsDockerRun = parts[4] == "docker";
|
||||
|
||||
//TODO: Add log call
|
||||
}
|
||||
|
||||
public async Task Restart()
|
||||
{
|
||||
Logger.Info("Restarting moonlight");
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
|
||||
<StatCard Value="@memoryUsageText" Description="Memory usage" Icon="bxs-microchip"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<StatCard Value="bf6641c (up-to-date)" Description="Version" Icon="bxs-purchase-tag"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
@{
|
||||
var uptimeText = Formatter.FormatUptime(Uptime);
|
||||
@@ -40,7 +37,30 @@
|
||||
<StatCard Value="@uptimeText" Description="Uptime" Icon="bxs-time-five"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<StatCard Value="@OsName" Description="Operating system" Icon="bx-fingerprint"/>
|
||||
@if (MoonlightService.IsDockerRun)
|
||||
{
|
||||
<StatCard Value="Running in docker" Description="Operating system" Icon="bxl-docker"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<StatCard Value="@OsName" Description="Operating system" Icon="bx-fingerprint"/>
|
||||
}
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
@{
|
||||
var commitText = $"{MoonlightService.BuildCommitHash} (up-to-date)";
|
||||
}
|
||||
|
||||
<StatCard Value="@commitText" Description="Commit" Icon="bxl-git"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<StatCard Value="@MoonlightService.BuildChannel" Description="Channel" Icon="bx-git-branch"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<StatCard Value="@MoonlightService.BuildName" Description="Name" Icon="bxs-bookmark"/>
|
||||
</div>
|
||||
<div class="col-md-3 col-12">
|
||||
<StatCard Value="@MoonlightService.BuildVersion" Description="Version" Icon="bxs-purchase-tag"/>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
@@ -74,7 +94,9 @@
|
||||
{
|
||||
await lazyLoader.SetText("Loading system statistics");
|
||||
|
||||
OsName = await HostSystemHelper.GetOsName();
|
||||
if(!MoonlightService.IsDockerRun)
|
||||
OsName = await HostSystemHelper.GetOsName();
|
||||
|
||||
CpuUsage = await HostSystemHelper.GetCpuUsage();
|
||||
MemoryUsage = await HostSystemHelper.GetMemoryUsage();
|
||||
Uptime = await MoonlightService.GetUptime();
|
||||
|
||||
@@ -17,6 +17,13 @@ ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "Moonlight.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
|
||||
# Define args
|
||||
ARG BUILD_CHANNEL=unknown
|
||||
ARG BUILD_COMMIT_HASH=unknown
|
||||
ARG BUILD_NAME=unknown
|
||||
ARG BUILD_VERSION=unknown
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
@@ -24,4 +31,11 @@ COPY --from=publish /app/publish .
|
||||
RUN mkdir -p /app/Assets
|
||||
COPY ./Moonlight/Assets ./Assets
|
||||
|
||||
# Ensure storage folder exists and is empty
|
||||
RUN mkdir -p /app/storage
|
||||
RUN rm -rf /app/storage/*
|
||||
|
||||
# Version the build
|
||||
RUN echo "$BUILD_CHANNEL;$BUILD_COMMIT_HASH;$BUILD_NAME;$BUILD_VERSION;docker" > /app/version
|
||||
|
||||
ENTRYPOINT ["dotnet", "Moonlight.dll"]
|
||||
|
||||
Reference in New Issue
Block a user