Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install libssh

- name: Build
run: make

- name: Build with AddressSanitizer
run: make asan

- name: Run basic tests
run: |
timeout 10 ./tnt &
sleep 2
pkill tnt || true

- name: Check for memory leaks
if: runner.os == 'Linux'
run: |
sudo apt-get install -y valgrind
timeout 10 valgrind --leak-check=full --error-exitcode=1 ./tnt &
sleep 5
pkill tnt || true
133 changes: 133 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-amd64
artifact: tnt-linux-amd64
- os: ubuntu-latest
target: linux-arm64
artifact: tnt-linux-arm64
- os: macos-latest
target: darwin-amd64
artifact: tnt-darwin-amd64
- os: macos-latest
target: darwin-arm64
artifact: tnt-darwin-arm64

steps:
- uses: actions/checkout@v4

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libssh-dev

- name: Install cross-compilation tools (Ubuntu ARM64)
if: matrix.target == 'linux-arm64'
run: |
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo dpkg --add-architecture arm64

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install libssh

- name: Build release binary
run: make release

- name: Rename binary
run: mv tnt ${{ matrix.artifact }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}

release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts

- name: Create checksums
run: |
cd artifacts
for dir in */; do
cd "$dir"
sha256sum * > checksums.txt
cd ..
done
cd ..

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/*/tnt-*
artifacts/*/checksums.txt
body: |
## Installation

Download the binary for your platform:

**Linux AMD64:**
```bash
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/tnt-linux-amd64
chmod +x tnt-linux-amd64
sudo mv tnt-linux-amd64 /usr/local/bin/tnt
```

**Linux ARM64:**
```bash
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/tnt-linux-arm64
chmod +x tnt-linux-arm64
sudo mv tnt-linux-arm64 /usr/local/bin/tnt
```

**macOS Intel:**
```bash
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/tnt-darwin-amd64
chmod +x tnt-darwin-amd64
sudo mv tnt-darwin-amd64 /usr/local/bin/tnt
```

**macOS Apple Silicon:**
```bash
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/tnt-darwin-arm64
chmod +x tnt-darwin-arm64
sudo mv tnt-darwin-arm64 /usr/local/bin/tnt
```

**Verify checksums:**
```bash
sha256sum -c checksums.txt
```

## What's Changed
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md)
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94 changes: 94 additions & 0 deletions CICD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
CI/CD USAGE GUIDE
=================

AUTOMATIC TESTING
-----------------
Every push or PR automatically runs:
- Build on Ubuntu and macOS
- AddressSanitizer checks
- Valgrind memory leak detection

Check status:
https://github.com/m1ngsama/TNT/actions


CREATING RELEASES
-----------------
1. Update version in CHANGELOG.md

2. Create and push tag:
git tag v1.0.0
git push origin v1.0.0

3. GitHub Actions automatically:
- Builds binaries (Linux/macOS, AMD64/ARM64)
- Creates release
- Uploads binaries
- Generates checksums

4. Release appears at:
https://github.com/m1ngsama/TNT/releases


DEPLOYING TO SERVERS
--------------------
Single command on any server:
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh

Or with specific version:
VERSION=v1.0.0 curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh


PRODUCTION SETUP (systemd)
---------------------------
1. Install binary (see above)

2. Setup service:
sudo useradd -r -s /bin/false tnt
sudo mkdir -p /var/lib/tnt
sudo chown tnt:tnt /var/lib/tnt
sudo cp tnt.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now tnt

3. Check status:
sudo systemctl status tnt
sudo journalctl -u tnt -f


UPDATING SERVERS
----------------
Stop service:
sudo systemctl stop tnt

Run installer again:
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh

Restart:
sudo systemctl start tnt


PLATFORMS SUPPORTED
-------------------
✓ Linux AMD64 (x86_64)
✓ Linux ARM64 (aarch64)
✓ macOS Intel (x86_64)
✓ macOS Apple Silicon (arm64)


EXAMPLE WORKFLOW
----------------
# Local development
make && make asan
./tnt

# Create release
git tag v1.0.1
git push origin v1.0.1
# Wait 5 minutes for builds

# Deploy to production servers
for server in server1 server2 server3; do
ssh $server "curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | VERSION=v1.0.1 sh"
ssh $server "sudo systemctl restart tnt"
done
117 changes: 117 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# DEPLOYMENT

## Quick Install

One-line install (latest release):
```bash
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh
```

Specific version:
```bash
VERSION=v1.0.0 curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh
```

## Manual Install

Download binary for your platform from [releases](https://github.com/m1ngsama/TNT/releases):

```bash
# Linux AMD64
wget https://github.com/m1ngsama/TNT/releases/latest/download/tnt-linux-amd64
chmod +x tnt-linux-amd64
sudo mv tnt-linux-amd64 /usr/local/bin/tnt

# macOS ARM64 (Apple Silicon)
wget https://github.com/m1ngsama/TNT/releases/latest/download/tnt-darwin-arm64
chmod +x tnt-darwin-arm64
sudo mv tnt-darwin-arm64 /usr/local/bin/tnt
```

## systemd Service

1. Create user and directory:
```bash
sudo useradd -r -s /bin/false tnt
sudo mkdir -p /var/lib/tnt
sudo chown tnt:tnt /var/lib/tnt
```

2. Install service file:
```bash
sudo cp tnt.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable tnt
sudo systemctl start tnt
```

3. Check status:
```bash
sudo systemctl status tnt
sudo journalctl -u tnt -f
```

## Configuration

Environment variables:
```bash
# Change port
sudo systemctl edit tnt
# Add:
[Service]
Environment="PORT=3333"

sudo systemctl restart tnt
```

## Firewall

```bash
# Ubuntu/Debian
sudo ufw allow 2222/tcp

# CentOS/RHEL
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --reload
```

## Update

```bash
# Stop service
sudo systemctl stop tnt

# Re-run install script
curl -sSL https://raw.githubusercontent.com/m1ngsama/TNT/main/install.sh | sh

# Start service
sudo systemctl start tnt
```

## Uninstall

```bash
sudo systemctl stop tnt
sudo systemctl disable tnt
sudo rm /etc/systemd/system/tnt.service
sudo systemctl daemon-reload
sudo rm /usr/local/bin/tnt
sudo userdel tnt
sudo rm -rf /var/lib/tnt
```

## Docker (Alternative)

```dockerfile
FROM alpine:latest
RUN apk add --no-cache libssh
COPY tnt /usr/local/bin/tnt
EXPOSE 2222
CMD ["/usr/local/bin/tnt"]
```

Build and run:
```bash
docker build -t tnt .
docker run -d -p 2222:2222 --name tnt tnt
```
Loading