Skip to content

Commit

Permalink
Display version at startup (#43)
Browse files Browse the repository at this point in the history
* Removed Azure build system

* Version display on startup in docker containers

* use const as version

* Did code replacement instead of env
  • Loading branch information
helto4real committed Mar 24, 2020
1 parent 082d4e8 commit e3686e8
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 198 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/push_addon_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "Set version number"
run: |
sed -i '/ const string _version = /c\ const string _version = "dev build";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
- name: Run deploy script using builder
run: docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ${{github.workspace}}/addon:/data homeassistant/amd64-builder -t /data --all --docker-user ${{ secrets.DOCKER_USERNAME }} --docker-password ${{ secrets.DOCKER_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/push_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "Set version number"
run: |
sed -i '/ const string _version = /c\ const string _version = "master build";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/push_docker_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "Set version number"
run: |
sed -i '/ const string _version = /c\ const string _version = "dev build";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
- name: Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tags_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
- uses: olegtarasov/get-tag@v2
name: Set tag envronment variable
- name: "Set version number"
run: |
sed -i '/ const string _version = /c\ const string _version = "${GIT_TAG_NAME}";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tags_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
- uses: actions/setup-dotnet@v1
- uses: olegtarasov/get-tag@v2
name: Set tag envronment variable
- name: "Set version number"
run: |
sed -i '/ const string _version = /c\ const string _version = "${GIT_TAG_NAME}";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
- name: pack DaemonRunner
run: dotnet pack src/DaemonRunner/DaemonRunner/DaemonRunner.csproj --configuration Release -p:PackageVersion=${GIT_TAG_NAME}-alpha
- name: pack App
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Build the NetDaemon with build container
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.200-alpine as build

COPY . ./temp/
Expand All @@ -6,16 +7,17 @@ RUN \
mkdir -p /data \
\
&& dotnet \
publish \
./temp/src/Service/Service.csproj \
-c Release \
-o ./temp/dist \
\
publish \
./temp/src/Service/Service.csproj \
-c Release \
-o ./temp/dist \
\
&& mv ./temp/dist /app \
&& rm -R ./temp


# Build the target container
FROM ludeeus/container:dotnet-base

COPY --from=build /app /app

ENV \
Expand Down
64 changes: 0 additions & 64 deletions azure/azure-pipelines.yml

This file was deleted.

63 changes: 0 additions & 63 deletions azure/netdaemon-ci-pipeline.yml

This file was deleted.

63 changes: 0 additions & 63 deletions azure/netdaemon-release.yml

This file was deleted.

7 changes: 5 additions & 2 deletions src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

namespace JoySoftware.HomeAssistant.NetDaemon.DaemonRunner.Service
{

public class RunnerService : BackgroundService
{
const string _version = "dev";

private NetDaemonHost? _daemonHost;
private readonly ILogger<RunnerService> _logger;
private readonly ILoggerFactory _loggerFactory;
Expand All @@ -43,7 +46,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
try
{
_logger.LogInformation("Starting netdaemon...");
_logger.LogInformation($"Starting netdaemon (version {_version})...");

var config = await ReadConfigAsync();

Expand Down Expand Up @@ -168,7 +171,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
if (!File.Exists(exampleFilePath))
{
var json = JsonSerializer.Serialize(new HostConfig());

using (var fileStream = new FileStream(exampleFilePath, FileMode.CreateNew))
{
var options = new JsonSerializerOptions { WriteIndented = true, IgnoreNullValues = true };
Expand Down

0 comments on commit e3686e8

Please sign in to comment.