From d8d50f6dcb65d4b5484ea7c71a608cac401d8891 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Thu, 11 Mar 2021 18:19:25 +0100 Subject: [PATCH 01/19] Added workflow to build debian/ubuntu packages --- .github/workflows/deb-packaging.yml | 67 +++++++++++++++++++ Build/deb-meta/DEBIAN/control | 10 +++ Build/deb-meta/DEBIAN/copyright | 26 +++++++ Build/deb-meta/DEBIAN/postinst | 34 ++++++++++ Build/deb-meta/DEBIAN/postrm | 4 ++ .../etc/systemd/system/mqttnet-server.service | 14 ++++ 6 files changed, 155 insertions(+) create mode 100644 .github/workflows/deb-packaging.yml create mode 100644 Build/deb-meta/DEBIAN/control create mode 100644 Build/deb-meta/DEBIAN/copyright create mode 100644 Build/deb-meta/DEBIAN/postinst create mode 100644 Build/deb-meta/DEBIAN/postrm create mode 100644 Build/deb-meta/etc/systemd/system/mqttnet-server.service diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml new file mode 100644 index 0000000..77b318c --- /dev/null +++ b/.github/workflows/deb-packaging.yml @@ -0,0 +1,67 @@ +# This is a basic workflow to help you get started with Actions + +name: Deb Packaging + +# Controls when the action will run. +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + FileVersion: + description: 'File Version' + required: true + default: '' + Version: + description: 'Version' + required: true + default: '' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build MQTTnetServer + run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release /p:FileVersion=${{ github.event.inputs.fileVersion }} /p:Version=${{ github.event.inputs.version }} --self-contained --runtime linux-x64 --framework net5.0 + + - name: Set up installation directory + run: mkdir -p packaging/opt/MQTTnetServer + + - name: Copy meta data + run: | + cp -R Build/deb-meta/* packaging/ + chmod 755 packaging/DEBIAN/postinst + chmod 755 packaging/DEBIAN/postrm + + - name: Move artifacts to packaging directory + run: cp -R Source/MQTTnet.Server/bin/Release/net5.0/linux-x64/publish/* packaging/opt/MQTTnetServer + + - name: Adjust files + run: | + rm packaging/opt/MQTTnetServer/appsettings.Development.json + mv packaging/opt/MQTTnetServer/appsettings.json packaging/opt/MQTTnetServer/appsettings.template.json + + - name: Adjust permissions + run: | + cd packaging/opt/MQTTnetServer + find . -type f | xargs chmod -R 644 + chmod 755 MQTTnet.Server + + - name: Generate MD5s + run: | + cd packaging/ + md5sum $(find * -type f -not -path 'DEBIAN/*') > DEBIAN/md5sums + + - name: Patch meta + run: sed -i 's/\$VERSION/${{ github.event.inputs.version }}/' packaging/DEBIAN/control + + - name: Package everything + run: dpkg-deb -v --build packaging/ mqttnet-server_${{ github.event.inputs.version }}.deb + + - name: Save artifact + uses: actions/upload-artifact@v2 + with: + name: mqttnet-server + path: mqttnet-server_${{ github.event.inputs.version }}.deb \ No newline at end of file diff --git a/Build/deb-meta/DEBIAN/control b/Build/deb-meta/DEBIAN/control new file mode 100644 index 0000000..0d57c29 --- /dev/null +++ b/Build/deb-meta/DEBIAN/control @@ -0,0 +1,10 @@ +Package: mqttnet-server +Version: $VERSION +Section: base +Priority: optional +Architecture: amd64 +Depends: +Suggests: +Maintainer: Damian Wolgast +Description: + MQTTnet Server is a standalone cross platform MQTT server (like mosquitto) basing on this library. diff --git a/Build/deb-meta/DEBIAN/copyright b/Build/deb-meta/DEBIAN/copyright new file mode 100644 index 0000000..decf080 --- /dev/null +++ b/Build/deb-meta/DEBIAN/copyright @@ -0,0 +1,26 @@ +The source of MQTTnet is at: +https://github.com/chkr1011/MQTTnet +Project is maintained by Christian Kratky + + +MIT License + +Copyright (c) 2021 Damian Wolgast + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Build/deb-meta/DEBIAN/postinst b/Build/deb-meta/DEBIAN/postinst new file mode 100644 index 0000000..af24f62 --- /dev/null +++ b/Build/deb-meta/DEBIAN/postinst @@ -0,0 +1,34 @@ +#!/bin/bash + +# Check if user exits +USER=mqttnetsrv +USEREXISTS=$(id -u $USER >/dev/null 2>&1; echo $?) +EC=0 +BASEPATH=/opt +INSTALLPATH=$BASEPATH/MQTTnetServer + +# If user does not exist, create it +if (( $USEREXISTS == 1 )); then + useradd -d $INSTALLPATH -m -r $USER + EC=$(echo $?) + + if (( $EC == 1 )); then + exit 1; + fi +fi + +# Set permissions on files +chown -R root:root $INSTALLPATH + +# Check if config does not exist and create it +if [ ! -f "$INSTALLPATH/appsettings.json" ]; then + cp $INSTALLPATH/appsettings.template.json $INSTALLPATH/appsettings.json +fi + +# Enable MQTTServer.NET to bind to IP interface +setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server + +chmod 644 /etc/systemd/system/mqttnet-server.service + +# Reload systemd because of new service file +systemctl daemon-reload \ No newline at end of file diff --git a/Build/deb-meta/DEBIAN/postrm b/Build/deb-meta/DEBIAN/postrm new file mode 100644 index 0000000..625b9b4 --- /dev/null +++ b/Build/deb-meta/DEBIAN/postrm @@ -0,0 +1,4 @@ +#!/bin/bash + +# Reload systemd because of absent service file +systemctl daemon-reload \ No newline at end of file diff --git a/Build/deb-meta/etc/systemd/system/mqttnet-server.service b/Build/deb-meta/etc/systemd/system/mqttnet-server.service new file mode 100644 index 0000000..4181624 --- /dev/null +++ b/Build/deb-meta/etc/systemd/system/mqttnet-server.service @@ -0,0 +1,14 @@ +[Unit] +Description=MQTTnetServer +After=network.target + +[Service] +ExecStart=/opt/MQTTnetServer/MQTTnet.Server +WorkingDirectory=/opt/MQTTnetServer +StandardOutput=inherit +StandardError=inherit +Restart=always +User=mqttnetsrv + +[Install] +WantedBy=multi-user.target \ No newline at end of file From 6cbb8d42e363de27b7957c69c368c61b57ea93bb Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 12:15:49 +0100 Subject: [PATCH 02/19] Added prerm to revoke service permissions --- .github/workflows/deb-packaging.yml | 1 + Build/deb-meta/DEBIAN/prerm | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 Build/deb-meta/DEBIAN/prerm diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 77b318c..2a4fbfa 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -34,6 +34,7 @@ jobs: cp -R Build/deb-meta/* packaging/ chmod 755 packaging/DEBIAN/postinst chmod 755 packaging/DEBIAN/postrm + chmod 755 packaging/DEBIAN/prerm - name: Move artifacts to packaging directory run: cp -R Source/MQTTnet.Server/bin/Release/net5.0/linux-x64/publish/* packaging/opt/MQTTnetServer diff --git a/Build/deb-meta/DEBIAN/prerm b/Build/deb-meta/DEBIAN/prerm new file mode 100644 index 0000000..4afcd3b --- /dev/null +++ b/Build/deb-meta/DEBIAN/prerm @@ -0,0 +1,7 @@ +#!/bin/bash + +BASEPATH=/opt +INSTALLPATH=$BASEPATH/MQTTnetServer + +# Remove permission to open ports +setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server \ No newline at end of file From 5c2879029bbf8365e64c89337ce16730b067ba1f Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 12:26:04 +0100 Subject: [PATCH 03/19] Added command to stop service before uninstalling --- Build/deb-meta/DEBIAN/prerm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Build/deb-meta/DEBIAN/prerm b/Build/deb-meta/DEBIAN/prerm index 4afcd3b..523505c 100644 --- a/Build/deb-meta/DEBIAN/prerm +++ b/Build/deb-meta/DEBIAN/prerm @@ -3,5 +3,8 @@ BASEPATH=/opt INSTALLPATH=$BASEPATH/MQTTnetServer +# Stop service before uninstalling +systemctl stop mqttnet-server + # Remove permission to open ports setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server \ No newline at end of file From 7e764c7f0f9102da285b96ee1abdf7ea0cdd00ee Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 12:36:14 +0100 Subject: [PATCH 04/19] Added revision (assuming 1) and architecture --- .github/workflows/deb-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 2a4fbfa..94111b2 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -65,4 +65,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: mqttnet-server - path: mqttnet-server_${{ github.event.inputs.version }}.deb \ No newline at end of file + path: mqttnet-server_${{ github.event.inputs.version }}-1_amd64.deb From 0ea4ae7501a1f898fc97f34c67d0ed31cb45ca96 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 12:40:02 +0100 Subject: [PATCH 05/19] Fix, forgot to rename file. --- .github/workflows/deb-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 94111b2..8852b29 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -59,7 +59,7 @@ jobs: run: sed -i 's/\$VERSION/${{ github.event.inputs.version }}/' packaging/DEBIAN/control - name: Package everything - run: dpkg-deb -v --build packaging/ mqttnet-server_${{ github.event.inputs.version }}.deb + run: dpkg-deb -v --build packaging/ mqttnet-server_${{ github.event.inputs.version }}-1_amd64.deb - name: Save artifact uses: actions/upload-artifact@v2 From 3ee785c781857cc62efdc8a0604a8cade66c15a2 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 14:17:38 +0100 Subject: [PATCH 06/19] Fixed user creation to not copy skel-files --- Build/deb-meta/DEBIAN/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build/deb-meta/DEBIAN/postinst b/Build/deb-meta/DEBIAN/postinst index af24f62..575d126 100644 --- a/Build/deb-meta/DEBIAN/postinst +++ b/Build/deb-meta/DEBIAN/postinst @@ -9,7 +9,7 @@ INSTALLPATH=$BASEPATH/MQTTnetServer # If user does not exist, create it if (( $USEREXISTS == 1 )); then - useradd -d $INSTALLPATH -m -r $USER + useradd -d $INSTALLPATH -r $USER EC=$(echo $?) if (( $EC == 1 )); then From 9cb12ac2ceffae6d3bae518aeaa27ead304e1571 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 14:39:51 +0100 Subject: [PATCH 07/19] Docker, check if systemctl exists before using it --- Build/deb-meta/DEBIAN/postinst | 19 ++++++++++++------- Build/deb-meta/DEBIAN/postrm | 9 +++++++-- Build/deb-meta/DEBIAN/prerm | 9 +++++++-- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Build/deb-meta/DEBIAN/postinst b/Build/deb-meta/DEBIAN/postinst index 575d126..cc82a77 100644 --- a/Build/deb-meta/DEBIAN/postinst +++ b/Build/deb-meta/DEBIAN/postinst @@ -9,12 +9,12 @@ INSTALLPATH=$BASEPATH/MQTTnetServer # If user does not exist, create it if (( $USEREXISTS == 1 )); then - useradd -d $INSTALLPATH -r $USER - EC=$(echo $?) + useradd -d $INSTALLPATH -r $USER + EC=$(echo $?) - if (( $EC == 1 )); then - exit 1; - fi + if (( $EC == 1 )); then + exit 1; + fi fi # Set permissions on files @@ -30,5 +30,10 @@ setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server chmod 644 /etc/systemd/system/mqttnet-server.service -# Reload systemd because of new service file -systemctl daemon-reload \ No newline at end of file +# Check if systemctl exists, does not exist in docker containers +SCTL=$(which systemct1l >/dev/null; echo $?) + +if [ "$SCTL" -eq "0" ]; then + # Reload systemd because of new service file + systemctl daemon-reload +fi \ No newline at end of file diff --git a/Build/deb-meta/DEBIAN/postrm b/Build/deb-meta/DEBIAN/postrm index 625b9b4..e23c877 100644 --- a/Build/deb-meta/DEBIAN/postrm +++ b/Build/deb-meta/DEBIAN/postrm @@ -1,4 +1,9 @@ #!/bin/bash -# Reload systemd because of absent service file -systemctl daemon-reload \ No newline at end of file +# Check if systemctl exists, does not exist in docker containers +SCTL=$(which systemct1l >/dev/null; echo $?) + +if [ "$SCTL" -eq "0" ]; then + # Reload systemd because of new service file + systemctl daemon-reload +fi \ No newline at end of file diff --git a/Build/deb-meta/DEBIAN/prerm b/Build/deb-meta/DEBIAN/prerm index 523505c..a86e53a 100644 --- a/Build/deb-meta/DEBIAN/prerm +++ b/Build/deb-meta/DEBIAN/prerm @@ -3,8 +3,13 @@ BASEPATH=/opt INSTALLPATH=$BASEPATH/MQTTnetServer -# Stop service before uninstalling -systemctl stop mqttnet-server +# Check if systemctl exists, does not exist in docker containers +SCTL=$(which systemct1l >/dev/null; echo $?) + +if [ "$SCTL" -eq "0" ]; then + # Stop service before uninstalling + systemctl stop mqttnet-server +fi # Remove permission to open ports setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server \ No newline at end of file From 897f0f36d105ca7bcc8d5ed25cad10b0643d9139 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 14:40:21 +0100 Subject: [PATCH 08/19] Fixed spelling --- Build/deb-meta/DEBIAN/postinst | 2 +- Build/deb-meta/DEBIAN/postrm | 2 +- Build/deb-meta/DEBIAN/prerm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Build/deb-meta/DEBIAN/postinst b/Build/deb-meta/DEBIAN/postinst index cc82a77..519899e 100644 --- a/Build/deb-meta/DEBIAN/postinst +++ b/Build/deb-meta/DEBIAN/postinst @@ -31,7 +31,7 @@ setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server chmod 644 /etc/systemd/system/mqttnet-server.service # Check if systemctl exists, does not exist in docker containers -SCTL=$(which systemct1l >/dev/null; echo $?) +SCTL=$(which systemctl >/dev/null; echo $?) if [ "$SCTL" -eq "0" ]; then # Reload systemd because of new service file diff --git a/Build/deb-meta/DEBIAN/postrm b/Build/deb-meta/DEBIAN/postrm index e23c877..2ae9367 100644 --- a/Build/deb-meta/DEBIAN/postrm +++ b/Build/deb-meta/DEBIAN/postrm @@ -1,7 +1,7 @@ #!/bin/bash # Check if systemctl exists, does not exist in docker containers -SCTL=$(which systemct1l >/dev/null; echo $?) +SCTL=$(which systemctl >/dev/null; echo $?) if [ "$SCTL" -eq "0" ]; then # Reload systemd because of new service file diff --git a/Build/deb-meta/DEBIAN/prerm b/Build/deb-meta/DEBIAN/prerm index a86e53a..fb77531 100644 --- a/Build/deb-meta/DEBIAN/prerm +++ b/Build/deb-meta/DEBIAN/prerm @@ -4,7 +4,7 @@ BASEPATH=/opt INSTALLPATH=$BASEPATH/MQTTnetServer # Check if systemctl exists, does not exist in docker containers -SCTL=$(which systemct1l >/dev/null; echo $?) +SCTL=$(which systemctl >/dev/null; echo $?) if [ "$SCTL" -eq "0" ]; then # Stop service before uninstalling From d2e1b121866e440cbb5d203be07693b6802f3639 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 15:18:13 +0100 Subject: [PATCH 09/19] Added check for availability of setcap --- Build/deb-meta/DEBIAN/postinst | 9 +++++++-- Build/deb-meta/DEBIAN/postrm | 1 - Build/deb-meta/DEBIAN/prerm | 9 ++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Build/deb-meta/DEBIAN/postinst b/Build/deb-meta/DEBIAN/postinst index 519899e..9a90e94 100644 --- a/Build/deb-meta/DEBIAN/postinst +++ b/Build/deb-meta/DEBIAN/postinst @@ -25,8 +25,13 @@ if [ ! -f "$INSTALLPATH/appsettings.json" ]; then cp $INSTALLPATH/appsettings.template.json $INSTALLPATH/appsettings.json fi -# Enable MQTTServer.NET to bind to IP interface -setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server + +# Check if setcap exists, does not exist in docker containers +SCAP=$(which setcap >/dev/null; echo $?) +if [ "$SCAP" -eq "0" ]; then + # Enable MQTTServer.NET to bind to IP interface + setcap CAP_NET_BIND_SERVICE=+eip $INSTALLPATH/MQTTnet.Server +fi chmod 644 /etc/systemd/system/mqttnet-server.service diff --git a/Build/deb-meta/DEBIAN/postrm b/Build/deb-meta/DEBIAN/postrm index 2ae9367..9db22d4 100644 --- a/Build/deb-meta/DEBIAN/postrm +++ b/Build/deb-meta/DEBIAN/postrm @@ -2,7 +2,6 @@ # Check if systemctl exists, does not exist in docker containers SCTL=$(which systemctl >/dev/null; echo $?) - if [ "$SCTL" -eq "0" ]; then # Reload systemd because of new service file systemctl daemon-reload diff --git a/Build/deb-meta/DEBIAN/prerm b/Build/deb-meta/DEBIAN/prerm index fb77531..ae23bca 100644 --- a/Build/deb-meta/DEBIAN/prerm +++ b/Build/deb-meta/DEBIAN/prerm @@ -5,11 +5,14 @@ INSTALLPATH=$BASEPATH/MQTTnetServer # Check if systemctl exists, does not exist in docker containers SCTL=$(which systemctl >/dev/null; echo $?) - if [ "$SCTL" -eq "0" ]; then # Stop service before uninstalling systemctl stop mqttnet-server fi -# Remove permission to open ports -setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server \ No newline at end of file +# Check if setcap exists, does not exist in docker containers +SCAP=$(which setcap >/dev/null; echo $?) +if [ "$SCAP" -eq "0" ]; then + # Remove permission to open ports + setcap CAP_NET_BIND_SERVICE=-eip $INSTALLPATH/MQTTnet.Server +fi \ No newline at end of file From 1b1f2db1e63d252f8ebcecc7a593897e153cb3a8 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 15:44:22 +0100 Subject: [PATCH 10/19] Added dependency to libssl --- Build/deb-meta/DEBIAN/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build/deb-meta/DEBIAN/control b/Build/deb-meta/DEBIAN/control index 0d57c29..02cc2c2 100644 --- a/Build/deb-meta/DEBIAN/control +++ b/Build/deb-meta/DEBIAN/control @@ -3,7 +3,7 @@ Version: $VERSION Section: base Priority: optional Architecture: amd64 -Depends: +Depends: libssl1.1 Suggests: Maintainer: Damian Wolgast Description: From 0f3d461c37ec96d6f9086cd4f6f23b6a897e6f87 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:27:18 +0100 Subject: [PATCH 11/19] Read version from MQTTnet.Server project file --- .github/workflows/deb-packaging.yml | 20 +++++++------------- Build/deb-meta/DEBIAN/control | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 8852b29..32b2e93 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -6,15 +6,6 @@ name: Deb Packaging on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - inputs: - FileVersion: - description: 'File Version' - required: true - default: '' - Version: - description: 'Version' - required: true - default: '' jobs: build: @@ -23,8 +14,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Parse version + run: echo "VERSION=$(grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep '[0-9\.]+' -o)" >> $GITHUB_ENV + - name: Build MQTTnetServer - run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release /p:FileVersion=${{ github.event.inputs.fileVersion }} /p:Version=${{ github.event.inputs.version }} --self-contained --runtime linux-x64 --framework net5.0 + run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 - name: Set up installation directory run: mkdir -p packaging/opt/MQTTnetServer @@ -56,13 +50,13 @@ jobs: md5sum $(find * -type f -not -path 'DEBIAN/*') > DEBIAN/md5sums - name: Patch meta - run: sed -i 's/\$VERSION/${{ github.event.inputs.version }}/' packaging/DEBIAN/control + run: sed -i 's/\VERSIONPLACEHOLDER/${{ env.VERSION }}/' packaging/DEBIAN/control - name: Package everything - run: dpkg-deb -v --build packaging/ mqttnet-server_${{ github.event.inputs.version }}-1_amd64.deb + run: dpkg-deb -v --build packaging/ mqttnet-server_${{ env.VERSION }}-1_amd64.deb - name: Save artifact uses: actions/upload-artifact@v2 with: name: mqttnet-server - path: mqttnet-server_${{ github.event.inputs.version }}-1_amd64.deb + path: mqttnet-server_${{ env.VERSION }}-1_amd64.deb diff --git a/Build/deb-meta/DEBIAN/control b/Build/deb-meta/DEBIAN/control index 02cc2c2..242444c 100644 --- a/Build/deb-meta/DEBIAN/control +++ b/Build/deb-meta/DEBIAN/control @@ -1,5 +1,5 @@ Package: mqttnet-server -Version: $VERSION +Version: VERSIONPLACEHOLDER Section: base Priority: optional Architecture: amd64 From 4d94e1a318eaf0f20132ef5674a76a7cc50ccc54 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:32:03 +0100 Subject: [PATCH 12/19] Debugging --- .github/workflows/deb-packaging.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 32b2e93..b892910 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -16,6 +16,13 @@ jobs: - name: Parse version run: echo "VERSION=$(grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep '[0-9\.]+' -o)" >> $GITHUB_ENV + + - name: Validate version + run: | + ls -la Source/MQTTnet.Server/MQTTnet.Server.csproj + ls -la + echo ${{ env.VERSION }} + echo $VERSION - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 From 493cad087ffa3d65f63c9ddad9a1aaf22dcd1b22 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:36:41 +0100 Subject: [PATCH 13/19] Fixed syntax --- .github/workflows/deb-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index b892910..310168b 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -5,7 +5,7 @@ name: Deb Packaging # Controls when the action will run. on: # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_dispatch jobs: build: From f0919487f2479943cd58f11b3061f7fdc6848baa Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:44:26 +0100 Subject: [PATCH 14/19] Debugging --- .github/workflows/deb-packaging.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 310168b..6e4f7f2 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -19,10 +19,20 @@ jobs: - name: Validate version run: | + echo "ls -la Source/MQTTnet.Server" + ls -la Source/MQTTnet.Server + echo "ls -la Source/MQTTnet.Server/MQTTnet.Server.csproj" ls -la Source/MQTTnet.Server/MQTTnet.Server.csproj + echo "ls-la" ls -la + echo "echo ${{ env.VERSION }}" echo ${{ env.VERSION }} + echo "echo $VERSION" echo $VERSION + echo "$VERSION" + cat Source/MQTTnet.Server/MQTTnet.Server.csproj + echo "grep" + grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep '[0-9\.]+' -o - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 From 413c68de443a83cc670804425b066451c2670680 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:47:53 +0100 Subject: [PATCH 15/19] Debugging --- .github/workflows/deb-packaging.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 6e4f7f2..3964d39 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -15,24 +15,17 @@ jobs: - uses: actions/checkout@v2 - name: Parse version - run: echo "VERSION=$(grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep '[0-9\.]+' -o)" >> $GITHUB_ENV + run: echo "VERSION=$(grep \ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o)" >> $GITHUB_ENV - name: Validate version run: | - echo "ls -la Source/MQTTnet.Server" - ls -la Source/MQTTnet.Server - echo "ls -la Source/MQTTnet.Server/MQTTnet.Server.csproj" - ls -la Source/MQTTnet.Server/MQTTnet.Server.csproj - echo "ls-la" - ls -la echo "echo ${{ env.VERSION }}" echo ${{ env.VERSION }} echo "echo $VERSION" echo $VERSION echo "$VERSION" - cat Source/MQTTnet.Server/MQTTnet.Server.csproj echo "grep" - grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep '[0-9\.]+' -o + grep \\ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 From f3d121120b59a5e300cb0125383e783709acf8ff Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:51:18 +0100 Subject: [PATCH 16/19] Debugging --- .github/workflows/deb-packaging.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 3964d39..528a7d7 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -19,6 +19,10 @@ jobs: - name: Validate version run: | + ls -la + ls -la Source + ls -la Source/MQTTnet.Server + [ -f "Source/MQTTnet.Server/MQTTnet.Server.csproj" ] && echo -1- echo "echo ${{ env.VERSION }}" echo ${{ env.VERSION }} echo "echo $VERSION" From 52139c6a99964b4456ec4a950c11c07ad9946da0 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 17:56:34 +0100 Subject: [PATCH 17/19] Debugging --- .github/workflows/deb-packaging.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 528a7d7..4cd2f91 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -19,17 +19,10 @@ jobs: - name: Validate version run: | - ls -la - ls -la Source - ls -la Source/MQTTnet.Server - [ -f "Source/MQTTnet.Server/MQTTnet.Server.csproj" ] && echo -1- - echo "echo ${{ env.VERSION }}" + echo environment echo ${{ env.VERSION }} - echo "echo $VERSION" echo $VERSION - echo "$VERSION" - echo "grep" - grep \\ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o + grep \ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 From aab4448980b03d10fc50a68cdbf4106c4c551d23 Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 18:01:31 +0100 Subject: [PATCH 18/19] Debugging --- .github/workflows/deb-packaging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index 4cd2f91..d64c999 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -15,14 +15,14 @@ jobs: - uses: actions/checkout@v2 - name: Parse version - run: echo "VERSION=$(grep \ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o)" >> $GITHUB_ENV + run: echo VERSION=$(grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]* -o) >> $GITHUB_ENV - name: Validate version run: | echo environment echo ${{ env.VERSION }} echo $VERSION - grep \ Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]+ -o + grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]* -o - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0 From e7c51e8dbc97245cfec8bf24a33e7672825fa53f Mon Sep 17 00:00:00 2001 From: Damian Wolgast Date: Fri, 12 Mar 2021 18:03:32 +0100 Subject: [PATCH 19/19] Extraction of Version from project file. --- .github/workflows/deb-packaging.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/deb-packaging.yml b/.github/workflows/deb-packaging.yml index d64c999..36aa7ee 100644 --- a/.github/workflows/deb-packaging.yml +++ b/.github/workflows/deb-packaging.yml @@ -16,13 +16,6 @@ jobs: - name: Parse version run: echo VERSION=$(grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]* -o) >> $GITHUB_ENV - - - name: Validate version - run: | - echo environment - echo ${{ env.VERSION }} - echo $VERSION - grep '' Source/MQTTnet.Server/MQTTnet.Server.csproj | grep [0-9\.]* -o - name: Build MQTTnetServer run: dotnet publish Source/MQTTnet.Server/MQTTnet.Server.csproj --configuration Release --self-contained --runtime linux-x64 --framework net5.0