Skip to content

Commit b8846c4

Browse files
committed
feat: add action to build .deb package
1 parent e9f5459 commit b8846c4

File tree

6 files changed

+137
-0
lines changed

6 files changed

+137
-0
lines changed

.github/init/action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Initialize build environment"
2+
description: "Sets up common tools and configurations for Rust builds"
3+
4+
inputs:
5+
toolchain:
6+
description: "Rust toolchain to use (stable/nightly)"
7+
required: false
8+
default: "stable"
9+
components:
10+
description: "Rust components to install"
11+
required: false
12+
default: ""
13+
install-clang:
14+
description: "Whether to install clang"
15+
required: false
16+
default: "true"
17+
setup-cache:
18+
description: "Whether to setup Rust cache"
19+
required: false
20+
default: "true"
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
with:
27+
persist-credentials: false
28+
29+
- name: Install Clang
30+
if: ${{ inputs.install-clang == 'true' }}
31+
run: sudo apt-get update && sudo apt-get install -y clang
32+
shell: bash
33+
34+
- name: Install lsof
35+
run: sudo apt-get install lsof -y
36+
shell: bash
37+
38+
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # stable
39+
with:
40+
toolchain: ${{ inputs.toolchain }}
41+
components: ${{ inputs.components }}
42+
43+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2
44+
if: ${{ inputs.setup-cache == 'true' }}
45+
with:
46+
cache-on-failure: true

.github/workflows/deb-build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build .deb package
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
build-deb:
9+
name: Build .deb package
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: Checkout sources
13+
uses: actions/checkout@v4
14+
15+
- name: Install stable toolchain
16+
uses: ./.github/actions/init
17+
18+
- name: Install `cargo-deb`
19+
run: cargo install cargo-deb
20+
21+
- name: Run cargo deb
22+
run: cargo deb --output tycho-toncenter.deb
23+
24+
- uses: actions/upload-artifact@v4
25+
with:
26+
name: tycho-toncenter.deb
27+
path: tycho-toncenter.deb

Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ tycho-util = { git = "https://github.com/broxus/tycho.git", rev = "c8805e86e4f78
6262
[build-dependencies]
6363
anyhow = "1.0"
6464

65+
[features]
66+
packaged = []
67+
68+
[package.metadata.deb]
69+
features = ["packaged"]
70+
depends = "libssl, zlib1g"
71+
section = "utility"
72+
assets = [
73+
[
74+
"target/release/tycho-toncenter",
75+
"/usr/local/bin/tycho-toncenter",
76+
"755",
77+
],
78+
[
79+
"README.md",
80+
"/usr/share/doc/tycho-toncenter/README",
81+
"644",
82+
],
83+
]
84+
conf-files = ["/etc/tycho-toncenter/"]
85+
maintainer-scripts = "debian/"
86+
systemd-units = [
87+
{ unit-name = "tycho-toncenter", enable = true, start = false, stop-on-upgrade = false },
88+
]
89+
6590
[workspace.lints.rust]
6691
future_incompatible = "warn"
6792
nonstandard_style = "warn"

debian/postinst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
set -e
3+
4+
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then
5+
useradd tycho -r || echo "User already exists."
6+
path="/var/tycho-toncenter"
7+
8+
mkdir -p $path
9+
10+
chown tycho:tycho -R $path
11+
chmod 770 -R $path
12+
chmod g+s -R $path
13+
fi
14+
#DEBHELPER#

debian/prerm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
4+
deluser tycho || echo "User is currently used by process"
5+
groupdel tycho || echo "Group is currently used"
6+
7+
#DEBHELPER#

debian/tycho-toncenter.service

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Tycho TON Center API
3+
After=network.target
4+
StartLimitIntervalSec=0
5+
6+
[Service]
7+
Type=simple
8+
User=tycho
9+
LimitNOFILE=2048000
10+
WorkingDirectory=/var/tycho-toncenter
11+
ExecStart=/usr/local/bin/tycho-toncenter run \
12+
--config /etc/tycho-toncenter/config.json \
13+
--global-config /etc/tycho-toncenter/global-config.json \
14+
--keys keys.json
15+
Environment=RUST_BACKTRACE=1,RUST_LIB_BACKTRACE=0
16+
17+
[Install]
18+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)