diff --git a/.github/workflows/container.yaml b/.github/workflows/container.yaml new file mode 100644 index 0000000..7494393 --- /dev/null +++ b/.github/workflows/container.yaml @@ -0,0 +1,72 @@ +name: Container image + +# Mirrors .gitea/workflows/container.yaml — publishes a multi-arch +# (amd64 + arm64) image to the GitHub Container Registry whenever the +# Gitea→GitHub mirror pushes a `v*` tag. Image lands at +# ghcr.io/axodouble/quptime with tags :vX.Y.Z, :X.Y, and :latest. +on: + push: + tags: + - 'v*' + +permissions: + contents: read + packages: write + +jobs: + image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + # GHCR namespaces must be lowercase. Lowercase the repository + # path once and reuse below so a mixed-case org/repo (e.g. + # Axodouble/QUptime) still resolves to a valid image reference. + - name: Resolve image name + id: img + run: | + repo='${{ github.repository }}' + echo "ref=ghcr.io/${repo,,}" >> "$GITHUB_OUTPUT" + + - name: Compute version + id: ver + run: | + echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.img.outputs.ref }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.ver.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..02b199b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,60 @@ +name: Release + +# Mirrors .gitea/workflows/release.yaml — fires when the Gitea→GitHub +# mirror pushes a `v*` tag, builds static Linux binaries for amd64 + +# arm64, and publishes them to GitHub Releases alongside the Gitea +# release the same tag produces upstream. +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + check-latest: false + cache: false + + - name: Test + run: go test -race ./... + + - name: Build binaries + env: + CGO_ENABLED: '0' + run: | + set -euo pipefail + VERSION="${GITHUB_REF_NAME}" + mkdir -p dist + for arch in amd64 arm64; do + out="dist/qu-${VERSION}-linux-${arch}" + echo "building ${out}" + GOOS=linux GOARCH="${arch}" \ + go build \ + -trimpath \ + -ldflags "-s -w -X main.version=${VERSION}" \ + -o "${out}" \ + ./cmd/qu + done + (cd dist && sha256sum qu-* > SHA256SUMS) + ls -lh dist + + - name: Publish release + uses: softprops/action-gh-release@v2 + with: + files: | + dist/qu-* + dist/SHA256SUMS + fail_on_unmatched_files: true + generate_release_notes: true + token: ${{ secrets.GITHUB_TOKEN }}