Files
mtproxy_checker/.gitea/workflows/tdlib_ping.yaml
T
Denozordec e0c289e08d
Publish mtproxy_checker Docker image / test (push) Successful in 7s
Build tdlib_ping (linux/amd64) / build-tdlib-ping (push) Failing after 30s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 49s
Update tdlib_ping workflow to trigger on any branch and tag, aligning with Docker workflow triggers. Revise README to reflect changes in CI build process, clarifying artifact retrieval for both branch pushes and manual runs.
2026-04-11 16:24:52 +07:00

102 lines
3.2 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:
runs-on: ubuntu-latest
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 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}"