TNT/.github/workflows/release.yml
m1ngsama 8e24ae5633 Add CI/CD and deployment automation
GitHub Actions workflows:
- ci.yml: Auto-test on push/PR
  * Build on Ubuntu and macOS
  * Run AddressSanitizer
  * Memory leak checks with Valgrind

- release.yml: Auto-release on tags
  * Build for Linux (amd64, arm64)
  * Build for macOS (amd64, arm64)
  * Generate checksums
  * Create GitHub release with binaries

Deployment tools:
- install.sh: One-line installer
  * Auto-detect OS and arch
  * Download from releases
  * Install to /usr/local/bin

- tnt.service: systemd unit file
  * Auto-restart on failure
  * Security hardening
  * Runs as dedicated user

- DEPLOYMENT.md: Complete deployment guide
  * Quick install
  * systemd setup
  * Firewall config
  * Docker alternative

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

Create release:
  git tag v1.0.0
  git push origin v1.0.0
2025-12-02 12:47:15 +08:00

133 lines
3.4 KiB
YAML

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 }}