mirror of
https://github.com/telemt/telemt.git
synced 2026-05-17 08:26:39 +03:00
260 lines
7.0 KiB
YAML
260 lines
7.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '[0-9]+.[0-9]+.[0-9]+'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: release-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
BINARY_NAME: telemt
|
|
|
|
# ==========================
|
|
# GNU / glibc
|
|
# ==========================
|
|
jobs:
|
|
build-gnu:
|
|
name: GNU ${{ matrix.target }}
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
asset: telemt-x86_64-linux-gnu
|
|
- target: aarch64-unknown-linux-gnu
|
|
asset: telemt-aarch64-linux-gnu
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
targets: |
|
|
x86_64-unknown-linux-gnu
|
|
aarch64-unknown-linux-gnu
|
|
|
|
- name: Install deps
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
build-essential \
|
|
clang \
|
|
lld \
|
|
pkg-config \
|
|
gcc-aarch64-linux-gnu \
|
|
g++-aarch64-linux-gnu
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: gnu-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build
|
|
run: |
|
|
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
|
|
export CC=aarch64-linux-gnu-gcc
|
|
export CXX=aarch64-linux-gnu-g++
|
|
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
|
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
|
export RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc"
|
|
else
|
|
export CC=clang
|
|
export CXX=clang++
|
|
export CC_x86_64_unknown_linux_gnu=clang
|
|
export CXX_x86_64_unknown_linux_gnu=clang++
|
|
export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=lld"
|
|
fi
|
|
|
|
cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Package
|
|
run: |
|
|
mkdir -p dist
|
|
BIN=target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}
|
|
|
|
cp "$BIN" dist/${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
|
|
cd dist
|
|
tar -czf ${{ matrix.asset }}.tar.gz ${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
sha256sum ${{ matrix.asset }}.tar.gz > ${{ matrix.asset }}.sha256
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.asset }}
|
|
path: |
|
|
dist/${{ matrix.asset }}.tar.gz
|
|
dist/${{ matrix.asset }}.sha256
|
|
|
|
# ==========================
|
|
# MUSL (isolated environment)
|
|
# ==========================
|
|
build-musl:
|
|
name: MUSL ${{ matrix.target }}
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
image: rust:1.75-slim-bookworm
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-musl
|
|
asset: telemt-x86_64-linux-musl
|
|
- target: aarch64-unknown-linux-musl
|
|
asset: telemt-aarch64-linux-musl
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install deps (musl env)
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y \
|
|
musl-tools \
|
|
pkg-config \
|
|
curl
|
|
|
|
- name: Install aarch64 musl toolchain
|
|
if: matrix.target == 'aarch64-unknown-linux-musl'
|
|
run: |
|
|
curl -LO https://musl.cc/aarch64-linux-musl-cross.tgz
|
|
tar -xzf aarch64-linux-musl-cross.tgz
|
|
echo "$PWD/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH
|
|
|
|
- name: Add rust target
|
|
run: rustup target add ${{ matrix.target }}
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
/usr/local/cargo/registry
|
|
/usr/local/cargo/git
|
|
target
|
|
key: musl-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Build
|
|
run: |
|
|
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then
|
|
export CC=aarch64-linux-musl-gcc
|
|
export CC_aarch64_unknown_linux_musl=aarch64-linux-musl-gcc
|
|
export RUSTFLAGS="-C target-feature=+crt-static -C linker=aarch64-linux-musl-gcc"
|
|
else
|
|
export CC=musl-gcc
|
|
export CC_x86_64_unknown_linux_musl=musl-gcc
|
|
export RUSTFLAGS="-C target-feature=+crt-static"
|
|
fi
|
|
|
|
cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Package
|
|
run: |
|
|
mkdir -p dist
|
|
BIN=target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}
|
|
|
|
cp "$BIN" dist/${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
|
|
cd dist
|
|
tar -czf ${{ matrix.asset }}.tar.gz ${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
sha256sum ${{ matrix.asset }}.tar.gz > ${{ matrix.asset }}.sha256
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.asset }}
|
|
path: |
|
|
dist/${{ matrix.asset }}.tar.gz
|
|
dist/${{ matrix.asset }}.sha256
|
|
|
|
# ==========================
|
|
# Docker
|
|
# ==========================
|
|
docker:
|
|
name: Docker
|
|
runs-on: ubuntu-latest
|
|
needs: [build-gnu, build-musl]
|
|
continue-on-error: true
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Extract binaries
|
|
run: |
|
|
mkdir dist
|
|
find artifacts -name "*.tar.gz" -exec tar -xzf {} -C dist \;
|
|
|
|
cp dist/telemt-x86_64-unknown-linux-musl dist/telemt || true
|
|
|
|
- uses: docker/setup-qemu-action@v3
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract version
|
|
id: vars
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build & Push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.VERSION }}
|
|
ghcr.io/${{ github.repository }}:latest
|
|
build-args: |
|
|
BINARY=dist/telemt
|
|
|
|
# ==========================
|
|
# Release
|
|
# ==========================
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
needs: [build-gnu, build-musl]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Flatten artifacts
|
|
run: |
|
|
mkdir dist
|
|
find artifacts -type f -exec cp {} dist/ \;
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: dist/*
|
|
generate_release_notes: true
|
|
draft: false
|
|
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
|