mirror of
https://github.com/telemt/telemt.git
synced 2026-06-17 02:00:09 +07:00
178 lines
4.7 KiB
YAML
178 lines
4.7 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
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.target }}
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# ===== GNU / glibc =====
|
|
- target: x86_64-unknown-linux-gnu
|
|
asset_name: telemt-x86_64-linux-gnu
|
|
- target: aarch64-unknown-linux-gnu
|
|
asset_name: telemt-aarch64-linux-gnu
|
|
|
|
# ===== MUSL =====
|
|
- target: x86_64-unknown-linux-musl
|
|
asset_name: telemt-x86_64-linux-musl
|
|
- target: aarch64-unknown-linux-musl
|
|
asset_name: telemt-aarch64-linux-musl
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: dtolnay/rust-toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Pull cross images
|
|
run: |
|
|
docker pull ghcr.io/cross-rs/${{ matrix.target }}:latest || true
|
|
|
|
- name: Install cross
|
|
run: cargo install cross --git https://github.com/cross-rs/cross
|
|
|
|
- uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
target
|
|
key: ${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.target }}-
|
|
|
|
- name: Build
|
|
env:
|
|
RUSTFLAGS: ${{ contains(matrix.target, 'musl') && '-C target-feature=+crt-static' || '' }}
|
|
run: cross 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_name }}.tar.gz ${{ env.BINARY_NAME }}-${{ matrix.target }}
|
|
sha256sum ${{ matrix.asset_name }}.tar.gz > ${{ matrix.asset_name }}.sha256
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.asset_name }}
|
|
path: |
|
|
dist/${{ matrix.asset_name }}.tar.gz
|
|
dist/${{ matrix.asset_name }}.sha256
|
|
|
|
docker:
|
|
name: Docker
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
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 \;
|
|
|
|
# используем musl как runtime бинарь
|
|
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 prod
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
target: prod
|
|
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
|
|
|
|
- name: Build & Push debug
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
target: debug
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.VERSION }}-debug
|
|
ghcr.io/${{ github.repository }}:debug
|
|
build-args: |
|
|
BINARY=dist/telemt
|
|
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
|
|
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') }}
|