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
59 changes: 0 additions & 59 deletions .github/workflows/build.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

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

jobs:
test:
name: Test & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true

- name: Vet
run: go vet ./...

- name: Format check
run: test -z "$(gofmt -l .)"

- name: Test
run: go test ./...

build:
name: Build ${{ matrix.target.goos }}/${{ matrix.target.goarch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- { goos: linux, goarch: amd64 }
- { goos: linux, goarch: arm64 }
- { goos: darwin, goarch: amd64 }
- { goos: darwin, goarch: arm64 }
- { goos: windows, goarch: amd64 }
- { goos: android, goarch: arm64 }

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true

- name: Build all binaries
env:
GOOS: ${{ matrix.target.goos }}
GOARCH: ${{ matrix.target.goarch }}
CGO_ENABLED: 0
run: |
set -e
EXT=""; [ "$GOOS" = "windows" ] && EXT=".exe"
mkdir -p dist
go build -trimpath -ldflags="-s -w" -o "dist/tele-tui${EXT}" ./cmd/teletui
go build -trimpath -ldflags="-s -w" -o "dist/telegram-mcp${EXT}" ./cmd/telegram-mcp
go build -trimpath -ldflags="-s -w" -o "dist/telegram-api${EXT}" ./cmd/telegram-api

- uses: actions/upload-artifact@v4
with:
name: telegram-cli-${{ matrix.target.goos }}-${{ matrix.target.goarch }}
path: dist/
retention-days: 7
142 changes: 142 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Release

# Fully automatic: every push to main bumps the patch version, creates a
# tag, builds all platforms, and publishes a GitHub release.
# Put "#minor" or "#major" in the commit message to bump those instead.
# Pushing a v* tag manually also works (uses that tag as-is).
on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:

permissions:
contents: write

concurrency:
group: release
cancel-in-progress: false

jobs:
version:
name: Determine version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.ver.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- id: ver
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
set -e
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
TAG="$GITHUB_REF_NAME"
else
LATEST=$(git tag -l 'v*' --sort=-v:refname | head -n1)
LATEST=${LATEST:-v0.0.0}
IFS=. read -r MAJOR MINOR PATCH <<< "${LATEST#v}"
if grep -qi '#major' <<< "$COMMIT_MSG"; then
MAJOR=$((MAJOR+1)); MINOR=0; PATCH=0
elif grep -qi '#minor' <<< "$COMMIT_MSG"; then
MINOR=$((MINOR+1)); PATCH=0
else
PATCH=$((PATCH+1))
fi
TAG="v${MAJOR}.${MINOR}.${PATCH}"
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
PATCH=$((PATCH+1))
TAG="v${MAJOR}.${MINOR}.${PATCH}"
fi
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "Releasing ${TAG}"

build:
name: Build ${{ matrix.target.goos }}/${{ matrix.target.goarch }}
needs: [version]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- { goos: linux, goarch: amd64 }
- { goos: linux, goarch: arm64 }
- { goos: darwin, goarch: amd64 }
- { goos: darwin, goarch: arm64 }
- { goos: windows, goarch: amd64 }
- { goos: android, goarch: arm64 }

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache: true

- name: Build all binaries
env:
GOOS: ${{ matrix.target.goos }}
GOARCH: ${{ matrix.target.goarch }}
CGO_ENABLED: 0
run: |
set -e
EXT=""; [ "$GOOS" = "windows" ] && EXT=".exe"
mkdir -p dist
go build -trimpath -ldflags="-s -w" -o "dist/tele-tui${EXT}" ./cmd/teletui
go build -trimpath -ldflags="-s -w" -o "dist/telegram-mcp${EXT}" ./cmd/telegram-mcp
go build -trimpath -ldflags="-s -w" -o "dist/telegram-api${EXT}" ./cmd/telegram-api

- name: Package
env:
GOOS: ${{ matrix.target.goos }}
GOARCH: ${{ matrix.target.goarch }}
VERSION: ${{ needs.version.outputs.tag }}
run: |
set -e
PKG="telegram-cli_${VERSION}_${GOOS}_${GOARCH}"
mkdir -p "stage/${PKG}"
cp dist/* "stage/${PKG}/"
cp README.md LICENSE "stage/${PKG}/"
mkdir -p release
cd stage
if [ "$GOOS" = "windows" ]; then
zip -r "../release/${PKG}.zip" "${PKG}"
else
tar -czf "../release/${PKG}.tar.gz" "${PKG}"
fi

- uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.target.goos }}-${{ matrix.target.goarch }}
path: release/
retention-days: 7

publish:
name: Publish GitHub release
needs: [version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: package-*
path: packages
merge-multiple: true

- name: Generate checksums
run: |
cd packages
sha256sum *.tar.gz *.zip > checksums.txt

# softprops/action-gh-release creates the tag (pointing at this
# commit) when it does not exist yet — this is what makes the
# whole flow tagless on the pusher's side.
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.version.outputs.tag }}
name: ${{ needs.version.outputs.tag }}
files: packages/*
generate_release_notes: true
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>

<p align="center">
<a href="https://github.com/imtaqin/telegram-cli/actions"><img src="https://github.com/imtaqin/telegram-cli/actions/workflows/build.yml/badge.svg" alt="Build"></a>
<a href="https://github.com/imtaqin/telegram-cli/actions"><img src="https://github.com/imtaqin/telegram-cli/actions/workflows/ci.yml/badge.svg" alt="Build"></a>
<a href="https://github.com/imtaqin/telegram-cli/releases"><img src="https://img.shields.io/github/v/release/imtaqin/telegram-cli?include_prereleases" alt="Release"></a>
<a href="https://github.com/imtaqin/telegram-cli/blob/main/LICENSE"><img src="https://img.shields.io/github/license/imtaqin/telegram-cli" alt="License"></a>
<img src="https://img.shields.io/badge/Go-1.23+-00ADD8?logo=go&logoColor=white" alt="Go">
Expand Down Expand Up @@ -60,6 +60,12 @@

## Quick Start

### Prebuilt binaries

Download the latest release for your platform from [Releases](https://github.com/imtaqin/telegram-cli/releases) — Linux, macOS, Windows, and Android/Termux (arm64). Each archive contains all three binaries: `tele-tui`, `telegram-mcp`, `telegram-api`. Releases are fully automatic: every push to `main` bumps the patch version, tags, builds, and publishes (use `#minor` / `#major` in a commit message to bump those instead).

### Build from source

```bash
# Clone
git clone https://github.com/imtaqin/telegram-cli.git
Expand Down
Loading