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, darwin] goarch: [amd64, arm64] exclude: - goos: windows goarch: arm64 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}" -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: | 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}/${FILENAME}" \ --data-binary @${FILENAME} echo "Uploaded ${VERSION}/${FILENAME}" - name: Update latest tag if: gitea.ref == 'refs/heads/main' run: | 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/latest/${FILENAME}" \ --data-binary @${FILENAME} echo "Updated 'latest/${FILENAME}'" - name: Publish companion files (version + sha256) if: gitea.ref == 'refs/heads/main' run: | SHA256_HEX=$(sha256sum "${FILENAME}" | awk '{print $1}') # .version — идентификатор версии для авто-обновления printf '%s' "${VERSION}" > "${FILENAME}.version" # .sha256 — контрольная сумма бинаря (проверка U4) printf '%s' "${SHA256_HEX}" > "${FILENAME}.sha256" curl -sS -X PUT \ -H "Authorization: token ${{ secrets.TC_GITEA_TOKEN }}" \ -H "Content-Type: text/plain" \ "${{ vars.GIT_MAIN_URL }}/api/packages/${{ gitea.actor }}/generic/ratatoskr/latest/${FILENAME}.version" \ --data-binary @${FILENAME}.version curl -sS -X PUT \ -H "Authorization: token ${{ secrets.TC_GITEA_TOKEN }}" \ -H "Content-Type: text/plain" \ "${{ vars.GIT_MAIN_URL }}/api/packages/${{ gitea.actor }}/generic/ratatoskr/latest/${FILENAME}.sha256" \ --data-binary @${FILENAME}.sha256 echo "Published companion files for latest/${FILENAME}"