Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Initial for packagers #90

Merged
merged 9 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/arm_deb_packager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: arm_deb_packager


on:
push:
branches:
- 'main'
paths:
- '**'
tags:
- 'v*.*.*'
- 'v*.*.*-*'

jobs:
build:
permissions:
id-token: write
contents: write
runs-on:
labels: arm-runner-2204
steps:
- name: Checkout
uses: actions/checkout@v4
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: go mod download
run: go mod download

- name: build the binary
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: make build

- name: build the rust binary
run: cargo build --release --bin cdk
vcastellm marked this conversation as resolved.
Show resolved Hide resolved

- name: making directory structure
run: mkdir -p packaging/deb/cdk/usr/bin/
- name: copying necessary binary for arm64
run: cp -rp target/cdk-node packaging/deb/cdk/usr/bin/cdk-node
- name: copying rust binary for arm64
run: cp -rp target/release/cdk packaging/deb/cdk/usr/bin/cdk

# Control file creation
- name: create control file
run: |
echo "Package: cdk" >> packaging/deb/cdk/DEBIAN/control
echo "Version: ${{ env.VERSION }}" >> packaging/deb/cdk/DEBIAN/control
echo "Section: base" >> packaging/deb/cdk/DEBIAN/control
echo "Priority: optional" >> packaging/deb/cdk/DEBIAN/control
echo "Architecture: arm64" >> packaging/deb/cdk/DEBIAN/control
echo "Maintainer: devops@polygon.technology" >> packaging/deb/cdk/DEBIAN/control
echo "Description: cdk binary package" >> packaging/deb/cdk/DEBIAN/control

- name: Creating package for binary for cdk ${{ env.ARCH }}
run: cp -rp packaging/deb/cdk packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64

- name: Running package build
run: dpkg-deb --build --root-owner-group packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64

- name: create checksum for the arm64 package
run: cd packaging/deb/ && sha256sum cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum
env:
ARCH: arm64

- name: Release cdk Packages
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GIT_TAG }}
prerelease: true
files: |
packaging/deb/cdk**.deb
packaging/deb/cdk**.deb.checksum
vcastellm marked this conversation as resolved.
Show resolved Hide resolved
103 changes: 103 additions & 0 deletions .github/workflows/arm_rpm_packager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: arm_rpm_packager

on:
push:
branches:
- 'main'
paths:
- '**'
tags:
- 'v*.*.*'
- 'v*.*.*-*'

jobs:
build:
permissions:
id-token: write
contents: write
runs-on:
labels: arm-runner-2204
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.22.x
- name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV

- name: Adding a TAG.1 to the env
run: echo "GIT_TAG1=`echo $(git describe --tags --abbrev=0)`" | sed 's/-/./g' >> $GITHUB_ENV

- name: Download deps for project
run: go mod download

- name: Building cdk-node for amd64
run: make build

- name: Building the cdk
run: |
BUILD_SCRIPT_DISABLED=1
cargo build --release --bin cdk

- name: Installing some dependencies
run: sudo apt-get update && sudo apt-get install -y rpm

- name: Setup rpm package for binary
run: |
mkdir -p packaging/rpm/SPECS
mkdir -p packaging/rpm/BUILD
mkdir -p packaging/rpm/RPMS
mkdir -p packaging/rpm/SRPMS

touch packaging/rpm/cdk.spec
echo "Name: cdk" >> packaging/rpm/SPECS/cdk.spec
echo "Version: ${{ env.GIT_TAG1 }}" >> packaging/rpm/SPECS/cdk.spec
echo "Release: 1%{?dist}" >> packaging/rpm/SPECS/cdk.spec
echo "License: GPL/AGPL" >> packaging/rpm/SPECS/cdk.spec
echo "BuildArch: aarch64" >> packaging/rpm/SPECS/cdk.spec
echo "Summary: cdk rpm package" >> packaging/rpm/SPECS/cdk.spec

echo "%description" >> packaging/rpm/SPECS/cdk.spec
echo "cdk rpm package" >> packaging/rpm/SPECS/cdk.spec

echo "%pre" >> packaging/rpm/SPECS/cdk.spec
echo "getent group cdk >/dev/null || groupadd -r cdk" >> packaging/rpm/SPECS/cdk.spec
echo "getent passwd cdk >/dev/null || useradd -s /bin/false -d /opt/cdk -r cdk -g cdk" >> packaging/rpm/SPECS/cdk.spec

echo "%install" >> packaging/rpm/SPECS/cdk.spec
echo "mkdir -p %{buildroot}/usr/bin" >> packaging/rpm/SPECS/cdk.spec
echo "cp /home/runner/work/cdk/cdk/target/cdk-node %{buildroot}/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
echo "cp /home/runner/work/cdk/cdk/target/release/cdk %{buildroot}/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec

echo "%files" >> packaging/rpm/SPECS/cdk.spec
echo "/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
echo "/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec


- name: construct rpm package
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: |
rpmbuild --define "_topdir /home/runner/work/cdk/cdk/packaging/rpm_build" \
--define "_builddir %{_topdir}/BUILD" \
--define "_rpmdir %{_topdir}/RPMS" \
--define "_srcrpmdir %{_topdir}/SRPMS" \
--define "__spec_install_post /bin/true" \
-bb packaging/rpm/SPECS/cdk.spec

- name: rename file for post rpm build and for checksum
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: mv /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/aarch64/cdk-${{ env.GIT_TAG1 }}-1.aarch64.rpm /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/aarch64/cdk-${{ env.GIT_TAG1 }}.aarch64.rpm

- name: checksum for the rpm package
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: sha256sum /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/aarch64/cdk-${{ env.GIT_TAG1 }}.aarch64.rpm > /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/aarch64/cdk-${{ env.GIT_TAG1 }}.aarch64.rpm.checksum

- name: Release cdk Packages
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GIT_TAG }}
prerelease: true
files: |
packaging/rpm_build/RPMS/aarch64/cdk-**.rpm
packaging/rpm_build/RPMS/aarch64/cdk-**.rpm.checksum
87 changes: 87 additions & 0 deletions .github/workflows/x86_deb_packager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: x86_deb_packager


on:
push:
branches:
- 'main'
paths:
- '**'
tags:
- 'v*.*.*'
- 'v*.*.*-*'

jobs:
build:
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
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: go mod download
run: go mod download

- name: build the binary
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: make build

- name: build the rust binary
run: cargo build --release --bin cdk
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to remove this (see #88), wdyt?


- name: making directory structure
run: mkdir -p packaging/deb/cdk/usr/bin/
- name: copying necessary binary for amd64
run: cp -rp target/cdk-node packaging/deb/cdk/usr/bin/cdk-node
- name: copying rust binary for amd64
run: cp -rp target/release/cdk packaging/deb/cdk/usr/bin/cdk

# Control file creation
- name: create control file
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo "Package: cdk" >> packaging/deb/cdk/DEBIAN/control
echo "Version: ${{ env.VERSION }}" >> packaging/deb/cdk/DEBIAN/control
echo "Section: base" >> packaging/deb/cdk/DEBIAN/control
echo "Priority: optional" >> packaging/deb/cdk/DEBIAN/control
echo "Architecture: amd64" >> packaging/deb/cdk/DEBIAN/control
echo "Maintainer: devops@polygon.technology" >> packaging/deb/cdk/DEBIAN/control
echo "Description: cdk binary package" >> packaging/deb/cdk/DEBIAN/control

- name: Creating package for binary for cdk ${{ env.ARCH }}
run: cp -rp packaging/deb/cdk packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64

- name: Running package build
run: dpkg-deb --build --root-owner-group packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64

- name: create checksum for the amd64 package
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: cd packaging/deb/ && sha256sum cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum
env:
ARCH: amd64


- name: Release cdk Packages
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GIT_TAG }}
prerelease: true
files: |
packaging/deb/cdk**.deb
packaging/deb/cdk**.deb.checksum
vcastellm marked this conversation as resolved.
Show resolved Hide resolved
102 changes: 102 additions & 0 deletions .github/workflows/x86_rpm_packager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: x86_rpm_packager

on:
push:
branches:
- 'main'
paths:
- '**'
tags:
- 'v*.*.*'
- 'v*.*.*-*'

jobs:
build:
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.22.x
- name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV

- name: Adding a TAG.1 to the env
run: echo "GIT_TAG1=`echo $(git describe --tags --abbrev=0)`" | sed 's/-/./g' >> $GITHUB_ENV

- name: Download deps for project
run: go mod download

- name: Building cdk-node for amd64
run: make build

- name: Building the cdk
run: |
BUILD_SCRIPT_DISABLED=1
cargo build --release --bin cdk

- name: Installing some dependencies
run: sudo apt-get update && sudo apt-get install -y rpm

- name: Setup rpm package for binary
run: |
mkdir -p packaging/rpm/SPECS
mkdir -p packaging/rpm/BUILD
mkdir -p packaging/rpm/RPMS
mkdir -p packaging/rpm/SRPMS

touch packaging/rpm/cdk.spec
echo "Name: cdk" >> packaging/rpm/SPECS/cdk.spec
echo "Version: ${{ env.GIT_TAG1 }}" >> packaging/rpm/SPECS/cdk.spec
echo "Release: 1%{?dist}" >> packaging/rpm/SPECS/cdk.spec
echo "License: GPL/AGPL" >> packaging/rpm/SPECS/cdk.spec
echo "BuildArch: x86_64" >> packaging/rpm/SPECS/cdk.spec
echo "Summary: cdk rpm package" >> packaging/rpm/SPECS/cdk.spec

echo "%description" >> packaging/rpm/SPECS/cdk.spec
echo "cdk rpm package" >> packaging/rpm/SPECS/cdk.spec

echo "%pre" >> packaging/rpm/SPECS/cdk.spec
echo "getent group cdk >/dev/null || groupadd -r cdk" >> packaging/rpm/SPECS/cdk.spec
echo "getent passwd cdk >/dev/null || useradd -s /bin/false -d /opt/cdk -r cdk -g cdk" >> packaging/rpm/SPECS/cdk.spec

echo "%install" >> packaging/rpm/SPECS/cdk.spec
echo "mkdir -p %{buildroot}/usr/bin" >> packaging/rpm/SPECS/cdk.spec
echo "cp /home/runner/work/cdk/cdk/target/cdk-node %{buildroot}/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
echo "cp /home/runner/work/cdk/cdk/target/release/cdk %{buildroot}/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec

echo "%files" >> packaging/rpm/SPECS/cdk.spec
echo "/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
echo "/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec


- name: construct rpm package
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: |
rpmbuild --define "_topdir /home/runner/work/cdk/cdk/packaging/rpm_build" \
--define "_builddir %{_topdir}/BUILD" \
--define "_rpmdir %{_topdir}/RPMS" \
--define "_srcrpmdir %{_topdir}/SRPMS" \
--define "__spec_install_post /bin/true" \
-bb packaging/rpm/SPECS/cdk.spec

- name: rename file for post rpm build and for checksum
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: mv /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/x86_64/cdk-${{ env.GIT_TAG1 }}-1.x86_64.rpm /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/x86_64/cdk-${{ env.GIT_TAG1 }}.x86_64.rpm

- name: checksum for the rpm package
Stefan-Ethernal marked this conversation as resolved.
Show resolved Hide resolved
run: sha256sum /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/x86_64/cdk-${{ env.GIT_TAG1 }}.x86_64.rpm > /home/runner/work/cdk/cdk/packaging/rpm_build/RPMS/x86_64/cdk-${{ env.GIT_TAG1 }}.x86_64.rpm.checksum

- name: Release cdk Packages
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.GIT_TAG }}
prerelease: true
files: |
packaging/rpm_build/RPMS/x86_64/cdk-**.rpm
packaging/rpm_build/RPMS/x86_64/cdk-**.rpm.checksum
12 changes: 12 additions & 0 deletions packaging/deb/cdk/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# This is a postinstallation script so the service can be configured and started when requested
#
adduser --disabled-password --disabled-login --shell /usr/sbin/nologin --quiet --system --no-create-home --home /nonexistent cdk
if [ -d "/opt/cdk" ]
then
echo "Directory /opt/cdk exists."
else
mkdir -p /opt/cdk
chown -R cdk /opt/cdk
fi
systemctl daemon-reload
vcastellm marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading