Files
tony 11484920da
CI / validate (pull_request) Failing after 5m2s
fix(ci): run workflows on the Ubuntu runner image
2026-08-09 22:51:46 +02:00

100 lines
3.7 KiB
YAML

name: Release
on:
push:
tags:
- "v*.*.*"
jobs:
validate:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: tools/requirements-validation.txt
- run: python -m pip install --requirement tools/requirements-validation.txt
- name: Validate release tag
run: echo "$GITHUB_REF_NAME" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'
- name: Check formatting
run: test -z "$(gofmt -l .)"
- run: go test ./...
- run: CGO_ENABLED=0 go build ./...
- run: go test -race ./...
- run: go vet ./...
- run: go run honnef.co/go/tools/cmd/staticcheck@v0.6.1 ./...
- uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0
- run: python tools/validate_spec.py
publish:
needs: validate
runs-on: ubuntu-24.04
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Derive release metadata
shell: bash
run: |
version="${GITHUB_REF_NAME#v}"
echo "VERSION=$version" >> "$GITHUB_ENV"
if [[ "$version" == *-* ]]; then echo "PRERELEASE=true" >> "$GITHUB_ENV"; else echo "PRERELEASE=false" >> "$GITHUB_ENV"; fi
- name: Log in to the Gitea registry
shell: bash
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.zaynet.fr --username codex --password-stdin
- name: Publish application image
shell: bash
run: |
tags="--tag git.zaynet.fr/dogama/dogama:$VERSION"
if [[ "$PRERELEASE" == false ]]; then tags="$tags --tag git.zaynet.fr/dogama/dogama:latest"; fi
docker buildx build --platform linux/amd64,linux/arm64 --target dogama --build-arg VERSION="$GITHUB_REF_NAME" --build-arg COMMIT="$GITHUB_SHA" $tags --push .
- name: Publish agent image
shell: bash
run: |
tags="--tag git.zaynet.fr/dogama/dogama-agent:$VERSION"
if [[ "$PRERELEASE" == false ]]; then tags="$tags --tag git.zaynet.fr/dogama/dogama-agent:latest"; fi
docker buildx build --platform linux/amd64,linux/arm64 --target dogama-agent --build-arg VERSION="$GITHUB_REF_NAME" --build-arg COMMIT="$GITHUB_SHA" $tags --push .
- name: Build release archives
run: make release VERSION="$GITHUB_REF_NAME"
- name: Create release notes
shell: bash
run: |
previous="$(git describe --tags --abbrev=0 "$GITHUB_SHA^" 2>/dev/null || true)"
if [[ -n "$previous" ]]; then range="$previous..$GITHUB_SHA"; else range="$GITHUB_SHA"; fi
{
echo "Container images:"
echo "- git.zaynet.fr/dogama/dogama:$VERSION"
echo "- git.zaynet.fr/dogama/dogama-agent:$VERSION"
echo
echo "Changes included in this tag:"
git log --format='- %s (%h)' "$range"
} > release-notes.md
- name: Create Gitea release
env:
GITEA_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
GITEA_SERVER_URL: ${{ github.server_url }}
GITEA_REPOSITORY: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_COMMIT: ${{ github.sha }}
run: python tools/create_gitea_release.py release-notes.md