diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ce0cb8..25a436f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,4 +62,3 @@ jobs: env: GOTOOLCHAIN: auto KO_DOCKER_REPO: ghcr.io/iuclabs/encapi - KO_DEFAULTBASEIMAGE: gcr.io/distroless/static-debian12:nonroot diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77e5804..1267228 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,38 +2,31 @@ name: release on: push: - tags: ["v*"] + tags: ["v[0-9]*"] permissions: - contents: write - id-token: write + contents: read packages: write -env: - VAULT_ADDR: https://vault.service.consul:8200 - jobs: release: runs-on: iuclabs-release + env: + KO_DOCKER_REPO: ghcr.io/iuclabs/encapi + VERSION: ${{ github.ref_name }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 with: go-version-file: go.mod - - uses: hashicorp/vault-action@892a26828f195e65540a40b4768ae4571f51ebfc # v4.0.0 - with: - url: ${{ env.VAULT_ADDR }} - method: jwt - path: jwt/github/iuclabs - role: release - jwtGithubAudience: ${{ env.VAULT_ADDR }} - exportToken: true - - uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0 - with: - distribution: goreleaser - version: v2.20.2 - args: release --clean + - run: | + go install github.com/google/ko@v0.19.1 + go install github.com/google/go-containerregistry/cmd/crane@v0.22.1 + - run: echo "${GITHUB_TOKEN}" | crane auth login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: >- + ko build --bare --sbom=none --platform linux/amd64 --tags "${VERSION}" + --image-label org.opencontainers.image.source=https://github.com/IUCLabs/encapi + ./cmd/encapi + - run: crane tag "${KO_DOCKER_REPO}:${VERSION}" latest diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 8682b22..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,75 +0,0 @@ -version: 2 -project_name: encapi - -builds: - - &build - id: encapi-cli - main: ./cmd/encapi-cli - binary: encapi-cli - env: - - CGO_ENABLED=0 - mod_timestamp: "{{ .CommitTimestamp }}" - flags: - - -trimpath - ldflags: - - -s -w -X main.version={{ .Tag }} - goos: [linux] - goarch: [amd64] - - <<: *build - id: encapi - main: ./cmd/encapi - binary: encapi - -archives: - - formats: [none] - -nfpms: - - package_name: encapi-cli - ids: [encapi-cli] - bindir: /usr/local/bin - formats: [rpm] - file_name_template: "{{ .ConventionalFileName }}" - release: "1" - section: default - priority: extra - description: CLI + Puppet ENC entrypoint for encapi (External Node Classifier) - maintainer: Ben Vincent - homepage: https://git.unkin.net/unkin/encapi - license: MIT - replaces: [encapi-cli] - provides: [encapi-cli] - contents: - - src: packaging/encapi-enc - dst: /usr/local/bin/encapi-enc - file_info: - mode: 0755 - - src: packaging/enc.conf - dst: /etc/encapi/enc.conf - type: config|noreplace - file_info: - mode: 0644 - scripts: - preinstall: packaging/scripts/preinstall.sh - -kos: - - build: encapi - base_image: gcr.io/distroless/static-debian12:nonroot - repositories: [ghcr.io/iuclabs/encapi] - tags: ["{{ .Tag }}", latest] - bare: true - platforms: [linux/amd64] - sbom: none - labels: - org.opencontainers.image.source: https://github.com/IUCLabs/encapi - -checksum: - name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" - algorithm: sha256 - -signs: - - artifacts: checksum - cmd: scripts/sign.sh - args: ["${artifact}", "${signature}"] - -changelog: - disable: true diff --git a/.ko.yaml b/.ko.yaml new file mode 100644 index 0000000..3a16d69 --- /dev/null +++ b/.ko.yaml @@ -0,0 +1,6 @@ +defaultBaseImage: gcr.io/distroless/static-debian12:nonroot +builds: + - id: encapi + main: ./cmd/encapi + ldflags: + - -s -w -X main.version={{.Env.VERSION}} diff --git a/Makefile b/Makefile index ac67ac6..4efa26a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build build-server build-cli test test-short lint fmt e2e docker compose clean tidy rpm check-go patch minor major +.PHONY: build build-server build-cli test test-short lint fmt e2e docker compose clean tidy check-go patch minor major MODULE := git.unkin.net/unkin/encapi VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "0.0.0-dev") @@ -42,10 +42,6 @@ docker: compose: docker compose up -d -# Local snapshot of the release: encapi-cli RPM + encapi image (needs Docker). -rpm: - GOTOOLCHAIN=auto go run github.com/goreleaser/goreleaser/v2@v2.20.2 release --snapshot --clean --skip=sign - clean: rm -rf bin/ $(DIST)/ diff --git a/README.md b/README.md index dd89208..db1e608 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ keeping Puppet's node-classification contract byte-compatible. |-----------------|-----------------------------------------------------------------------| | `encapi` | HTTP server: serves ENC documents + a read/write API. Postgres-backed. | | `encapi-cli` | CLI over the API. `encapi-cli classify ` is the Puppet ENC. | -| `encapi-enc` | Thin wrapper (shipped in the RPM) for Puppet's `external_nodes`. | +| `encapi-enc` | Thin wrapper for Puppet's `external_nodes`. | The Terraform provider lives in a sibling repo: [`terraform-provider-encapi`](https://git.unkin.net/unkin/terraform-provider-encapi). @@ -130,9 +130,6 @@ make test-short # skip container-backed DB tests ## Releases -Tagging `vX.Y.Z` (`make patch|minor|major`) runs GoReleaser on GitHub Actions: - -- **`encapi` server image** — `ghcr.io/iuclabs/encapi:{tag,latest}` (distroless, built with ko). -- **`encapi-cli` RPM** — attached to the GitHub release with a signed - `SHA256SUMS`. Installs `encapi-cli`, the `encapi-enc` Puppet wrapper, and - `/etc/encapi/enc.conf`. +Tagging `vX.Y.Z` (`make patch|minor|major`) builds the `encapi` server image +with ko on GitHub Actions and pushes `ghcr.io/iuclabs/encapi:{tag,latest}` +(distroless). diff --git a/scripts/sign.sh b/scripts/sign.sh deleted file mode 100755 index e95575d..0000000 --- a/scripts/sign.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# Detached binary signature of $1 into $2 via the Vault gpg engine. -set -euo pipefail -b=$(base64 -w0 "$1") -jq -n --arg input "$b" '{input: $input, format: "base64"}' \ - | curl -sSf --cacert "${VAULT_CACERT:-/etc/vault-ca/ca.crt}" \ - -H "X-Vault-Token: ${VAULT_TOKEN}" -d @- \ - "${VAULT_ADDR}/v1/gpg/sign/iuclabs-release" \ - | jq -er .data.signature | base64 -d > "$2"