Files
mtproxy_checker/.gitea/workflows/tdlib_ping.yaml
T
Denozordec 07e35c5c87
Publish mtproxy_checker Docker image / test (push) Successful in 6s
Build tdlib_ping (linux/amd64) / build-tdlib-ping (push) Failing after 1m6s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 51s
Update tdlib_ping workflow to use Ubuntu 22.04 for compatibility with libtdjson-dev. Revise README to highlight the absence of the package in Ubuntu 24.04 and provide installation guidance for alternative distributions.
2026-04-11 16:27:00 +07:00

106 lines
3.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Сборка нативного tdlib_ping (CGO + libtdjson) под linux/amd64.
# Триггеры как у docker.yaml. На push ветки — только артефакт job; на push тега — артефакт + вложение в релиз Gitea (релиз создаётся при отсутствии).
name: Build tdlib_ping (linux/amd64)
on:
push:
branches:
- "**"
tags:
- "*"
workflow_dispatch:
permissions:
contents: write
env:
GO_VERSION: "1.22"
ASSET_NAME: tdlib_ping-linux-amd64
jobs:
build-tdlib-ping:
# Noble (24.04) не содержит libtdjson-dev в apt; на Jammy (22.04) пакет есть (universe).
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install libtdjson
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y universe
sudo apt-get update
sudo apt-get install -y libtdjson-dev jq
- name: Build tdlib_ping
env:
CGO_ENABLED: "1"
run: |
set -euo pipefail
go build -tags=tdlib -trimpath -ldflags="-s -w" -o "${ASSET_NAME}" ./cmd/tdlib_ping
chmod +x "${ASSET_NAME}"
file "${ASSET_NAME}"
ldd "${ASSET_NAME}" || true
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_NAME }}-${{ gitea.sha }}
path: ${{ env.ASSET_NAME }}
retention-days: 90
- name: Create release if needed and upload asset
if: ${{ startsWith(gitea.ref, 'refs/tags/') }}
env:
TOKEN: ${{ github.token }}
run: |
set -euo pipefail
SERVER="${{ gitea.server_url }}"
SERVER="${SERVER%/}"
REPO_FULL="${{ gitea.repository }}"
OWNER="${REPO_FULL%%/*}"
REPO="${REPO_FULL#*/}"
TAG="${{ gitea.ref_name }}"
ASSET_PATH="${{ env.ASSET_NAME }}"
ASSET_NAME="${{ env.ASSET_NAME }}"
api() {
curl -fsS -H "Authorization: token ${TOKEN}" -H "Accept: application/json" "$@"
}
code="$(api -o /tmp/rel.json -w "%{http_code}" \
"${SERVER}/api/v1/repos/${OWNER}/${REPO}/releases/tags/${TAG}")"
if [ "${code}" = "404" ]; then
api -X POST "${SERVER}/api/v1/repos/${OWNER}/${REPO}/releases" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false}" \
-o /tmp/rel.json
elif [ "${code}" != "200" ]; then
echo "unexpected HTTP ${code} from release-by-tag"
cat /tmp/rel.json || true
exit 1
fi
release_id="$(jq -r '.id' /tmp/rel.json)"
if [ "${release_id}" = "null" ] || [ -z "${release_id}" ]; then
echo "missing release id in response:"
cat /tmp/rel.json
exit 1
fi
curl -fsS -X POST \
-H "Authorization: token ${TOKEN}" \
-H "Accept: application/json" \
-F "attachment=@${ASSET_PATH};type=application/octet-stream" \
"${SERVER}/api/v1/repos/${OWNER}/${REPO}/releases/${release_id}/assets?name=${ASSET_NAME}"