Skip to content

Commit 2908a20

Browse files
authored
feat: Initial for packagers (#90)
* Initial for packagers * Adding BUILD_SCRIPT_DISABLED=1 to debian packagers
1 parent 749ceb8 commit 2908a20

File tree

8 files changed

+422
-1
lines changed

8 files changed

+422
-1
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: arm_deb_packager
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- 'main'
8+
paths:
9+
- '**'
10+
tags:
11+
- 'v*.*.*'
12+
- 'v*.*.*-*'
13+
14+
jobs:
15+
build:
16+
permissions:
17+
id-token: write
18+
contents: write
19+
runs-on:
20+
labels: arm-runner-2204
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Set up Go
27+
uses: actions/setup-go@master
28+
with:
29+
go-version: 1.22.x
30+
# Variables
31+
- name: Adding TAG to ENV
32+
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
33+
- name: adding version
34+
run: |
35+
NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' )
36+
echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV
37+
38+
- name: go mod download
39+
run: go mod download
40+
41+
- name: Build the binary
42+
run: make build
43+
44+
- name: Build the rust binary
45+
run: |
46+
BUILD_SCRIPT_DISABLED=1
47+
cargo build --release --bin cdk
48+
49+
- name: making directory structure
50+
run: mkdir -p packaging/deb/cdk/usr/bin/
51+
- name: copying necessary binary for arm64
52+
run: cp -rp target/cdk-node packaging/deb/cdk/usr/bin/cdk-node
53+
- name: copying rust binary for arm64
54+
run: cp -rp target/release/cdk packaging/deb/cdk/usr/bin/cdk
55+
56+
# Control file creation
57+
- name: Create control file
58+
run: |
59+
echo "Package: cdk" >> packaging/deb/cdk/DEBIAN/control
60+
echo "Version: ${{ env.VERSION }}" >> packaging/deb/cdk/DEBIAN/control
61+
echo "Section: base" >> packaging/deb/cdk/DEBIAN/control
62+
echo "Priority: optional" >> packaging/deb/cdk/DEBIAN/control
63+
echo "Architecture: arm64" >> packaging/deb/cdk/DEBIAN/control
64+
echo "Maintainer: [email protected]" >> packaging/deb/cdk/DEBIAN/control
65+
echo "Description: cdk binary package" >> packaging/deb/cdk/DEBIAN/control
66+
67+
- name: Creating package for binary for cdk ${{ env.ARCH }}
68+
run: cp -rp packaging/deb/cdk packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
69+
env:
70+
ARCH: arm64
71+
72+
- name: Running package build
73+
run: dpkg-deb --build --root-owner-group packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
74+
env:
75+
ARCH: arm64
76+
77+
- name: create checksum for the arm64 package
78+
run: cd packaging/deb/ && sha256sum cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum
79+
env:
80+
ARCH: arm64
81+
82+
- name: Release cdk Packages
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ env.GIT_TAG }}
86+
prerelease: true
87+
files: |
88+
packaging/deb/cdk**.deb
89+
packaging/deb/cdk**.deb.checksum
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: arm_rpm_packager
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '**'
9+
tags:
10+
- 'v*.*.*'
11+
- 'v*.*.*-*'
12+
13+
jobs:
14+
build:
15+
permissions:
16+
id-token: write
17+
contents: write
18+
runs-on:
19+
labels: arm-runner-2204
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Set up Go
26+
uses: actions/setup-go@master
27+
with:
28+
go-version: 1.22.x
29+
- name: Adding TAG to ENV
30+
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
31+
32+
- name: Adding a TAG.1 to the env
33+
run: echo "GIT_TAG1=`echo $(git describe --tags --abbrev=0)`" | sed 's/-/./g' >> $GITHUB_ENV
34+
35+
- name: Download deps for project
36+
run: go mod download
37+
38+
- name: Building cdk-node for amd64
39+
run: make build
40+
41+
- name: Building the cdk
42+
run: |
43+
BUILD_SCRIPT_DISABLED=1
44+
cargo build --release --bin cdk
45+
46+
- name: Installing some dependencies
47+
run: sudo apt-get update && sudo apt-get install -y rpm
48+
49+
- name: Setup rpm package for binary
50+
run: |
51+
mkdir -p packaging/rpm/SPECS
52+
mkdir -p packaging/rpm/BUILD
53+
mkdir -p packaging/rpm/RPMS
54+
mkdir -p packaging/rpm/SRPMS
55+
56+
touch packaging/rpm/cdk.spec
57+
echo "Name: cdk" >> packaging/rpm/SPECS/cdk.spec
58+
echo "Version: ${{ env.GIT_TAG1 }}" >> packaging/rpm/SPECS/cdk.spec
59+
echo "Release: 1%{?dist}" >> packaging/rpm/SPECS/cdk.spec
60+
echo "License: GPL/AGPL" >> packaging/rpm/SPECS/cdk.spec
61+
echo "BuildArch: aarch64" >> packaging/rpm/SPECS/cdk.spec
62+
echo "Summary: cdk rpm package" >> packaging/rpm/SPECS/cdk.spec
63+
64+
echo "%description" >> packaging/rpm/SPECS/cdk.spec
65+
echo "cdk rpm package" >> packaging/rpm/SPECS/cdk.spec
66+
67+
echo "%pre" >> packaging/rpm/SPECS/cdk.spec
68+
echo "getent group cdk >/dev/null || groupadd -r cdk" >> packaging/rpm/SPECS/cdk.spec
69+
echo "getent passwd cdk >/dev/null || useradd -s /bin/false -d /opt/cdk -r cdk -g cdk" >> packaging/rpm/SPECS/cdk.spec
70+
71+
echo "%install" >> packaging/rpm/SPECS/cdk.spec
72+
echo "mkdir -p %{buildroot}/usr/bin" >> packaging/rpm/SPECS/cdk.spec
73+
echo "cp /home/runner/work/cdk/cdk/target/cdk-node %{buildroot}/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
74+
echo "cp /home/runner/work/cdk/cdk/target/release/cdk %{buildroot}/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
75+
76+
echo "%files" >> packaging/rpm/SPECS/cdk.spec
77+
echo "/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
78+
echo "/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
79+
80+
81+
- name: Construct rpm package
82+
run: |
83+
rpmbuild --define "_topdir /home/runner/work/cdk/cdk/packaging/rpm_build" \
84+
--define "_builddir %{_topdir}/BUILD" \
85+
--define "_rpmdir %{_topdir}/RPMS" \
86+
--define "_srcrpmdir %{_topdir}/SRPMS" \
87+
--define "__spec_install_post /bin/true" \
88+
-bb packaging/rpm/SPECS/cdk.spec
89+
90+
- name: Rename file for post rpm build and for checksum
91+
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
92+
93+
- name: Checksum for the rpm package
94+
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
95+
96+
- name: Release cdk Packages
97+
uses: softprops/action-gh-release@v2
98+
with:
99+
tag_name: ${{ env.GIT_TAG }}
100+
prerelease: true
101+
files: |
102+
packaging/rpm_build/RPMS/aarch64/cdk-**.rpm
103+
packaging/rpm_build/RPMS/aarch64/cdk-**.rpm.checksum
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: x86_deb_packager
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- 'main'
8+
paths:
9+
- '**'
10+
tags:
11+
- 'v*.*.*'
12+
- 'v*.*.*-*'
13+
14+
jobs:
15+
build:
16+
permissions:
17+
id-token: write
18+
contents: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Set up Go
26+
uses: actions/setup-go@master
27+
with:
28+
go-version: 1.22.x
29+
# Variables
30+
- name: Adding TAG to ENV
31+
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
32+
- name: adding version
33+
run: |
34+
NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' )
35+
echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV
36+
37+
- name: go mod download
38+
run: go mod download
39+
40+
- name: Build the binary
41+
run: make build
42+
43+
- name: Build the rust binary
44+
run: |
45+
BUILD_SCRIPT_DISABLED=1
46+
cargo build --release --bin cdk
47+
48+
- name: making directory structure
49+
run: mkdir -p packaging/deb/cdk/usr/bin/
50+
- name: copying necessary binary for amd64
51+
run: cp -rp target/cdk-node packaging/deb/cdk/usr/bin/cdk-node
52+
- name: copying rust binary for amd64
53+
run: cp -rp target/release/cdk packaging/deb/cdk/usr/bin/cdk
54+
55+
# Control file creation
56+
- name: Create control file
57+
run: |
58+
echo "Package: cdk" >> packaging/deb/cdk/DEBIAN/control
59+
echo "Version: ${{ env.VERSION }}" >> packaging/deb/cdk/DEBIAN/control
60+
echo "Section: base" >> packaging/deb/cdk/DEBIAN/control
61+
echo "Priority: optional" >> packaging/deb/cdk/DEBIAN/control
62+
echo "Architecture: amd64" >> packaging/deb/cdk/DEBIAN/control
63+
echo "Maintainer: [email protected]" >> packaging/deb/cdk/DEBIAN/control
64+
echo "Description: cdk binary package" >> packaging/deb/cdk/DEBIAN/control
65+
66+
- name: Creating package for binary for cdk ${{ env.ARCH }}
67+
run: cp -rp packaging/deb/cdk packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
68+
env:
69+
ARCH: amd64
70+
71+
- name: Running package build
72+
run: dpkg-deb --build --root-owner-group packaging/deb/cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}
73+
env:
74+
ARCH: amd64
75+
76+
- name: Create checksum for the amd64 package
77+
run: cd packaging/deb/ && sha256sum cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb > cdk-${{ env.GIT_TAG }}-${{ env.ARCH }}.deb.checksum
78+
env:
79+
ARCH: amd64
80+
81+
82+
- name: Release cdk Packages
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ env.GIT_TAG }}
86+
prerelease: true
87+
files: |
88+
packaging/deb/cdk**.deb
89+
packaging/deb/cdk**.deb.checksum
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: x86_rpm_packager
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '**'
9+
tags:
10+
- 'v*.*.*'
11+
- 'v*.*.*-*'
12+
13+
jobs:
14+
build:
15+
permissions:
16+
id-token: write
17+
contents: write
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Set up Go
25+
uses: actions/setup-go@master
26+
with:
27+
go-version: 1.22.x
28+
- name: Adding TAG to ENV
29+
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
30+
31+
- name: Adding a TAG.1 to the env
32+
run: echo "GIT_TAG1=`echo $(git describe --tags --abbrev=0)`" | sed 's/-/./g' >> $GITHUB_ENV
33+
34+
- name: Download deps for project
35+
run: go mod download
36+
37+
- name: Building cdk-node for amd64
38+
run: make build
39+
40+
- name: Building the cdk
41+
run: |
42+
BUILD_SCRIPT_DISABLED=1
43+
cargo build --release --bin cdk
44+
45+
- name: Installing some dependencies
46+
run: sudo apt-get update && sudo apt-get install -y rpm
47+
48+
- name: Setup rpm package for binary
49+
run: |
50+
mkdir -p packaging/rpm/SPECS
51+
mkdir -p packaging/rpm/BUILD
52+
mkdir -p packaging/rpm/RPMS
53+
mkdir -p packaging/rpm/SRPMS
54+
55+
touch packaging/rpm/cdk.spec
56+
echo "Name: cdk" >> packaging/rpm/SPECS/cdk.spec
57+
echo "Version: ${{ env.GIT_TAG1 }}" >> packaging/rpm/SPECS/cdk.spec
58+
echo "Release: 1%{?dist}" >> packaging/rpm/SPECS/cdk.spec
59+
echo "License: GPL/AGPL" >> packaging/rpm/SPECS/cdk.spec
60+
echo "BuildArch: x86_64" >> packaging/rpm/SPECS/cdk.spec
61+
echo "Summary: cdk rpm package" >> packaging/rpm/SPECS/cdk.spec
62+
63+
echo "%description" >> packaging/rpm/SPECS/cdk.spec
64+
echo "cdk rpm package" >> packaging/rpm/SPECS/cdk.spec
65+
66+
echo "%pre" >> packaging/rpm/SPECS/cdk.spec
67+
echo "getent group cdk >/dev/null || groupadd -r cdk" >> packaging/rpm/SPECS/cdk.spec
68+
echo "getent passwd cdk >/dev/null || useradd -s /bin/false -d /opt/cdk -r cdk -g cdk" >> packaging/rpm/SPECS/cdk.spec
69+
70+
echo "%install" >> packaging/rpm/SPECS/cdk.spec
71+
echo "mkdir -p %{buildroot}/usr/bin" >> packaging/rpm/SPECS/cdk.spec
72+
echo "cp /home/runner/work/cdk/cdk/target/cdk-node %{buildroot}/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
73+
echo "cp /home/runner/work/cdk/cdk/target/release/cdk %{buildroot}/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
74+
75+
echo "%files" >> packaging/rpm/SPECS/cdk.spec
76+
echo "/usr/bin/cdk" >> packaging/rpm/SPECS/cdk.spec
77+
echo "/usr/bin/cdk-node" >> packaging/rpm/SPECS/cdk.spec
78+
79+
80+
- name: Construct rpm package
81+
run: |
82+
rpmbuild --define "_topdir /home/runner/work/cdk/cdk/packaging/rpm_build" \
83+
--define "_builddir %{_topdir}/BUILD" \
84+
--define "_rpmdir %{_topdir}/RPMS" \
85+
--define "_srcrpmdir %{_topdir}/SRPMS" \
86+
--define "__spec_install_post /bin/true" \
87+
-bb packaging/rpm/SPECS/cdk.spec
88+
89+
- name: Rename file for post rpm build and for checksum
90+
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
91+
92+
- name: Checksum for the rpm package
93+
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
94+
95+
- name: Release cdk Packages
96+
uses: softprops/action-gh-release@v2
97+
with:
98+
tag_name: ${{ env.GIT_TAG }}
99+
prerelease: true
100+
files: |
101+
packaging/rpm_build/RPMS/x86_64/cdk-**.rpm
102+
packaging/rpm_build/RPMS/x86_64/cdk-**.rpm.checksum

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ target/
88
book/
99
index.html
1010
tmp
11-
.vscode
11+
.vscode
12+
.idea
13+
.idea/*

0 commit comments

Comments
 (0)