Files
ratatoskr-go/.gitea/workflows/ci.yaml
Hermes 0142686592
All checks were successful
CI / test (push) Successful in 55s
CI / build-and-package (amd64, linux) (push) Successful in 41s
CI / build-and-package (amd64, windows) (push) Successful in 47s
ci: только linux/windows amd64 — mac/arm пока не нужны
2026-08-16 13:11:40 +05:00

83 lines
2.8 KiB
YAML
Raw Permalink 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.
name: CI
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- '.gitea/**'
- 'LICENSE'
pull_request:
workflow_dispatch:
concurrency:
group: ${{ gitea.workflow }}-${{ gitea.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Run tests
run: go test ./... -v -count=1 -timeout 120s 2>&1
- name: Vet
run: go vet ./...
build-and-package:
if: always()
needs: test
strategy:
matrix:
goos: [linux, windows]
goarch: [amd64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Build binary
run: |
FILENAME="ratatoskr-${{ matrix.goos }}-${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
FILENAME="${FILENAME}.exe"
fi
VERSION="commit-$(echo '${{ gitea.sha }}' | cut -c1-7)"
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -ldflags="-s -w -X main.version=${VERSION} -X main.updateToken=${{ secrets.TC_UPDATE_TOKEN }}" -o "${FILENAME}" ./cmd/ratatoskr/
echo "FILENAME=${FILENAME}" >> "${GITEA_ENV}"
echo "VERSION=${VERSION}" >> "${GITEA_ENV}"
- name: Show size
run: ls -lh "$FILENAME"
- name: Upload to Gitea Packages
if: gitea.ref == 'refs/heads/main'
run: |
SHA256_HEX=$(sha256sum "${FILENAME}" | awk '{print $1}')
# <filename>.version — идентификатор версии для авто-обновления
printf '%s' "${VERSION}" > "${FILENAME}.version"
# <filename>.sha256 — контрольная сумма бинаря (проверка U4)
printf '%s' "${SHA256_HEX}" > "${FILENAME}.sha256"
# Всё публикуется в КОНКРЕТНУЮ версию ${VERSION}, НЕ в псевдо-version "latest".
# "latest" в Gitea при параллельных PUT матрицы (6 платформ) переуказывается
# на каждый снимок — companion-файлы и бинарь разъезжаются, ломая checksum (U4).
for f in "${FILENAME}" "${FILENAME}.version" "${FILENAME}.sha256"; do
curl -sS -X PUT \
-H "Authorization: token ${{ secrets.TC_GITEA_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
"${{ vars.GIT_MAIN_URL }}/api/packages/${{ gitea.actor }}/generic/ratatoskr/${VERSION}/${f}" \
--data-binary @"${f}"
done
echo "Published ${VERSION}/{binary,.version,.sha256}"