1
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
2
+ USER $APP_UID
3
+ WORKDIR /app
4
+
5
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
6
+ ARG BUILD_CONFIGURATION=Release
7
+ WORKDIR /src
8
+ COPY ["src/SiteMonitor/SiteMonitor.csproj" , "src/SiteMonitor/" ]
9
+ RUN dotnet restore "src/SiteMonitor/SiteMonitor.csproj"
10
+ COPY src/ .
11
+ WORKDIR "/src/SiteMonitor"
12
+ RUN dotnet build "SiteMonitor.csproj" -c $BUILD_CONFIGURATION -o /app/build
13
+
14
+ FROM build AS publish
15
+ ARG BUILD_CONFIGURATION=Release
16
+ ARG TAG_VERSION
17
+ ARG GITHUB_TOKEN
18
+ ARG DESCRIPTION
19
+ RUN apt-get update && apt-get dist-upgrade -y && apt-get install zip jq -y
20
+
21
+ # Generate the executables
22
+ RUN dotnet publish "SiteMonitor.csproj" -c $BUILD_CONFIGURATION -o /app/publish/win-x64 -r win-x64
23
+ RUN dotnet publish "SiteMonitor.csproj" -c $BUILD_CONFIGURATION -o /app/publish/win-x86 -r win-x86
24
+ RUN cd /app/publish/win-x64 && zip -r ../windows-x64.zip *
25
+ RUN cd /app/publish/win-x86 && zip -r ../windows-x86.zip *
26
+
27
+ # Create a tag and associate it with a release in GitHub. We don't need to check if it already exist, if it already
28
+ # exists the command won't do anything.
29
+ RUN curl -L \
30
+ -X POST \
31
+ -H "Accept: application/vnd.github+json" \
32
+ -H "Authorization: Bearer $GITHUB_TOKEN" \
33
+ https://api.github.com/repos/nullinside-development-group/nullinside-site-monitor/releases \
34
+ -d '{"tag_name":"' $TAG_VERSION'","target_commitish":"main","name":"' $TAG_VERSION'","body":"' $DESCRIPTION'","draft":false,"prerelease":false,"generate_release_notes":false}'
35
+
36
+ # Upload the files to the release. We need to get the ID for the release we created first and then upload the zips.
37
+ # This needs to be done in a single run command to provide the $RELEASE_ID to the rest of the commands. We don't need to
38
+ # check if it already exist, if it already exists the command won't do anything.
39
+ RUN export RELEASE_ID=$(curl -L \
40
+ -H "Accept: application/vnd.github+json" \
41
+ -H "Authorization: Bearer $GITHUB_TOKEN" \
42
+ -H "X-GitHub-Api-Version: 2022-11-28" \
43
+ "https://api.github.com/repos/nullinside-development-group/nullinside-site-monitor/releases/latest" \
44
+ | jq .id) && \
45
+ echo "Release ID: " $RELEASE_ID && \
46
+ curl -L \
47
+ -X POST \
48
+ -H "Accept: application/vnd.github+json" \
49
+ -H "Authorization: Bearer $GITHUB_TOKEN" \
50
+ -H "Content-Type: application/octet-stream" \
51
+ "https://uploads.github.com/repos/nullinside-development-group/nullinside-site-monitor/releases/$RELEASE_ID/assets?name=windows-x64.zip" \
52
+ --data-binary "@/app/publish/windows-x64.zip" && \
53
+ curl -L \
54
+ -X POST \
55
+ -H "Accept: application/vnd.github+json" \
56
+ -H "Authorization: Bearer $GITHUB_TOKEN" \
57
+ -H "Content-Type: application/octet-stream" \
58
+ "https://uploads.github.com/repos/nullinside-development-group/nullinside-site-monitor/releases/$RELEASE_ID/assets?name=windows-x86.zip" \
59
+ --data-binary "@/app/publish/windows-x86.zip"
0 commit comments