From 47086549deabae4061fd08042a8019446ad00e0d Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Tue, 25 Jun 2024 15:03:40 -0500 Subject: [PATCH] Adding initial for deb packaging for amd64 --- .github/workflows/deb_packager.yml | 89 +++++++++++++++++++ Makefile | 4 + .../deb/cdk-validium-node/DEBIAN/postinst | 12 +++ packaging/deb/cdk-validium-node/DEBIAN/postrm | 8 ++ packaging/systemd/cdk-validium-node.service | 16 ++++ 5 files changed, 129 insertions(+) create mode 100644 .github/workflows/deb_packager.yml create mode 100755 packaging/deb/cdk-validium-node/DEBIAN/postinst create mode 100755 packaging/deb/cdk-validium-node/DEBIAN/postrm create mode 100644 packaging/systemd/cdk-validium-node.service diff --git a/.github/workflows/deb_packager.yml b/.github/workflows/deb_packager.yml new file mode 100644 index 0000000000..c87271bd9c --- /dev/null +++ b/.github/workflows/deb_packager.yml @@ -0,0 +1,89 @@ +name: deb_packager +# test + +on: + push: + branches: + - 'main' + paths: + - '**' + tags: + - 'v*.*.*' + - 'v*.*.*-*' + +jobs: + build: + permissions: + id-token: write + contents: write + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@master + with: + go-version: 1.22.x + # Variables + - name: Adding TAG to ENV + run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV + - name: adding version + run: | + NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' ) + echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV + + - name: make clean for good measure + run: make clean + + - name: build the binary + run: make build + + - name: making directory structure + run: mkdir -p packaging/deb/cdk-validium-node/usr/bin/ + - name: creating DEBIAN directory + run: mkdir -p packaging/deb/cdk-validium-node/DEBIAN + - name: copying necessary binary for amd64 + run: cp -rp dist/zkevm-node packaging/deb/cdk-validium-node/usr/bin/cdk-validium-node + - name: create directory for service file + run: mkdir -p packaging/deb/cdk-validium-node/lib/systemd/system + - name: copy the service file + run: cp -rp packaging/systemd/cdk-validium-node.service packaging/deb/cdk-validium-node/lib/systemd/system/ + + + # Control file creation + - name: create control file + run: | + echo "Package: cdk-validium-node" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Version: ${{ env.VERSION }}" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Section: base" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Priority: optional" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Architecture: amd64" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Maintainer: devops@polygon.technology" >> packaging/deb/cdk-validium-node/DEBIAN/control + echo "Description: cdk-validium-node binary package" >> packaging/deb/cdk-validium-node/DEBIAN/control + + - name: Creating package for binary for cdk-validium-node ${{ env.ARCH }} + run: cp -rp packaging/deb/cdk-validium-node packaging/deb/cdk-validium-node-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: Running package build + run: dpkg-deb --build --root-owner-group packaging/deb/cdk-validium-node-${{ env.GIT_TAG }}-${{ env.ARCH }} + env: + ARCH: amd64 + + - name: create checksum for the amd64 package + run: cd packaging/deb/ && sha256sum cdk-validium-node-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > cdk-validium-node-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum + env: + ARCH: amd64 + + + - name: Release cdk-validium-node Packages + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.GIT_TAG }} + prerelease: true + files: | + packaging/deb/cdk-validium-node**.deb + packaging/deb/cdk-validium-node**.deb.checksum \ No newline at end of file diff --git a/Makefile b/Makefile index 83d4fed5fe..22c44567fa 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,10 @@ check-python: check-curl: @which curl > /dev/null || (echo "Error: curl is not installed" && exit 1) +clean: + env GO111MODULE=on go clean -cache + rm -fr build/_workspace/pkg/ $(GOBIN)/* + # Targets that require the checks build: check-go lint: check-go diff --git a/packaging/deb/cdk-validium-node/DEBIAN/postinst b/packaging/deb/cdk-validium-node/DEBIAN/postinst new file mode 100755 index 0000000000..8b8d7da73f --- /dev/null +++ b/packaging/deb/cdk-validium-node/DEBIAN/postinst @@ -0,0 +1,12 @@ +#!/bin/bash +# This is a postinstallation script so the service can be configured and started when requested +# +sudo adduser --disabled-password --disabled-login --shell /usr/sbin/nologin --quiet --system --no-create-home --home /nonexistent cdk-validium-node +if [ -d "/opt/cdk-validium-node" ] +then + echo "Directory /opt/cdk-validium-node exists." +else + mkdir -p /opt/cdk-validium-node + sudo chown -R cdk-validium-node /opt/cdk-validium-node +fi +sudo systemctl daemon-reload \ No newline at end of file diff --git a/packaging/deb/cdk-validium-node/DEBIAN/postrm b/packaging/deb/cdk-validium-node/DEBIAN/postrm new file mode 100755 index 0000000000..a5084c99a3 --- /dev/null +++ b/packaging/deb/cdk-validium-node/DEBIAN/postrm @@ -0,0 +1,8 @@ +#!/bin/bash +# +############### +# Remove cdk-data-availability installs +############## +sudo rm -rf /lib/systemd/system/cdk-validium-node.service +sudo deluser cdk-validium-node +sudo systemctl daemon-reload \ No newline at end of file diff --git a/packaging/systemd/cdk-validium-node.service b/packaging/systemd/cdk-validium-node.service new file mode 100644 index 0000000000..83c5618194 --- /dev/null +++ b/packaging/systemd/cdk-validium-node.service @@ -0,0 +1,16 @@ +Unit] + Description=cdk-validium-node + StartLimitIntervalSec=500 + StartLimitBurst=5 + +[Service] + Restart=on-failure + RestartSec=5s + ExecStart=/usr/bin/cdk-validium-node + Type=simple + KillSignal=SIGINT + User=cdk-validium-node + TimeoutStopSec=120 + +[Install] + WantedBy=multi-user.target \ No newline at end of file