Add GitHub Actions CI and GoReleaser release
ci/woodpecker/pr/pre-commit Pipeline was successful
ci / pre-commit (pull_request) Has been cancelled
ci / lint (pull_request) Has been cancelled
ci / test (pull_request) Has been cancelled
ci / build (pull_request) Has been cancelled
ci/woodpecker/pr/build Pipeline was canceled
ci/woodpecker/pr/test Pipeline was canceled
ci/woodpecker/pr/pre-commit Pipeline was successful
ci / pre-commit (pull_request) Has been cancelled
ci / lint (pull_request) Has been cancelled
ci / test (pull_request) Has been cancelled
ci / build (pull_request) Has been cancelled
ci/woodpecker/pr/build Pipeline was canceled
ci/woodpecker/pr/test Pipeline was canceled
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* @IUCLabs/maintainers
|
||||
@@ -0,0 +1,66 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
pre-commit:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
|
||||
- run: uvx pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
lint:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
|
||||
with:
|
||||
version: v2.15.0
|
||||
|
||||
test:
|
||||
runs-on: iuclabs-k8s
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
# runner image has no C toolchain, so no -race
|
||||
- run: go test -count=1 ./...
|
||||
|
||||
build:
|
||||
runs-on: iuclabs-k8s
|
||||
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
|
||||
- run: go build -trimpath -ldflags="-s -w" ./...
|
||||
- uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: v2.20.2
|
||||
args: check
|
||||
- uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: v2.20.2
|
||||
args: release --snapshot --clean --skip=sign,publish
|
||||
@@ -0,0 +1,38 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
env:
|
||||
VAULT_ADDR: https://vault.service.consul:8200
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: iuclabs-release
|
||||
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
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
+4
-8
@@ -62,14 +62,10 @@ checksum:
|
||||
split: true
|
||||
name_template: "{{ .ArtifactName }}.sha256"
|
||||
|
||||
release:
|
||||
gitea:
|
||||
owner: unkin
|
||||
name: encapic
|
||||
|
||||
gitea_urls:
|
||||
api: https://git.unkin.net/api/v1
|
||||
download: https://git.unkin.net
|
||||
signs:
|
||||
- artifacts: checksum
|
||||
cmd: scripts/sign.sh
|
||||
args: ["${artifact}", "${signature}"]
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
when:
|
||||
- event: tag
|
||||
ref: refs/tags/v*
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: "artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.3-alma9"
|
||||
environment:
|
||||
GOCACHE_S3_BUCKET: gocache
|
||||
GOCACHE_S3_REGION: us-east-1
|
||||
GOCACHE_S3_ENDPOINT_URL: "https://s3.ceph.unkin.net"
|
||||
GOCACHE_S3_PATH_STYLE: "true"
|
||||
GOCACHE_KEY_PREFIX: ci-encapic
|
||||
GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: GOCACHE_AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
- go test -race ./...
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 512Mi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 2Gi
|
||||
cpu: 2
|
||||
|
||||
# goreleaser is the single driver for the release: it builds the static
|
||||
# binary, builds the RPM (nfpm is built in) and creates the Gitea release
|
||||
# with the binary, RPM and per-artifact sha256 files attached. The binary
|
||||
# asset name is unchanged — the puppet compilers pull it at pod start.
|
||||
- name: goreleaser
|
||||
image: "artifactapi.k8s.syd1.au.unkin.net/docker-internal/gobuilder:0.1.3-alma9"
|
||||
environment:
|
||||
GITEA_TOKEN:
|
||||
from_secret: RELEASER_TOKEN
|
||||
GOCACHE_S3_BUCKET: gocache
|
||||
GOCACHE_S3_REGION: us-east-1
|
||||
GOCACHE_S3_ENDPOINT_URL: "https://s3.ceph.unkin.net"
|
||||
GOCACHE_S3_PATH_STYLE: "true"
|
||||
GOCACHE_KEY_PREFIX: ci-encapic
|
||||
GOCACHEPROG: go-cache-plugin --cache-dir=/tmp/gocache
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: GOCACHE_AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: GOCACHE_AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
# goreleaser reads the tag history for the changelog; Woodpecker's clone
|
||||
# can be shallow.
|
||||
- git fetch --tags --force
|
||||
- go install github.com/goreleaser/goreleaser/v2@v2.17.1
|
||||
- goreleaser release --clean
|
||||
depends_on: [test]
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 512Mi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 2Gi
|
||||
cpu: 2
|
||||
|
||||
# goreleaser cannot PUT to artifactapi, so the RPM it built into dist/ is
|
||||
# published to the local rpm repo here (a real yum repo; repodata
|
||||
# regenerates automatically).
|
||||
- name: upload-rpm
|
||||
image: git.unkin.net/unkin/almalinux9-base:20260606
|
||||
commands:
|
||||
- |
|
||||
HOST="https://artifactapi.k8s.syd1.au.unkin.net"
|
||||
REPO="rpm-internal"
|
||||
set -o pipefail
|
||||
VAULT="https://vault.service.consul:8200"
|
||||
AUTH=$$(mktemp)
|
||||
VT=$$(jq -n --rawfile jwt /var/run/secrets/kubernetes.io/serviceaccount/token '{role:"woodpecker_artifactapi_writer",jwt:$$jwt}' \
|
||||
| curl -sf -d @- "$$VAULT/v1/auth/k8s/au/syd1/login" | jq -er .auth.client_token) || exit 1
|
||||
printf 'X-Vault-Token: %s\n' "$$VT" | curl -sf -H @- "$$VAULT/v1/identity/oidc/token/artifactapi-writer" \
|
||||
| jq -er '"Authorization: Bearer " + .data.token' > "$$AUTH" || exit 1
|
||||
for rpm in dist/*.rpm; do
|
||||
FILE=$$(basename "$$rpm")
|
||||
# artifactapi has no HEAD route (returns 405); probe with GET against
|
||||
# the served path (RPMs are stored under Packages/) to avoid re-upload.
|
||||
code=$$(curl -s -o /dev/null -w '%{http_code}' "$$HOST/api/v2/remotes/$$REPO/files/Packages/$$FILE" || true)
|
||||
if [ "$$code" = "200" ]; then
|
||||
echo "$$FILE already exists in $$REPO (HTTP $$code); skipping upload"
|
||||
continue
|
||||
fi
|
||||
echo "Uploading $$FILE to $$REPO (existence probe returned $$code)"
|
||||
curl -f -X PUT \
|
||||
"$$HOST/api/v2/remotes/$$REPO/files/$$FILE" \
|
||||
-H "Content-Type: application/x-rpm" -H @"$$AUTH" \
|
||||
--data-binary @"$$rpm"
|
||||
done
|
||||
depends_on: [goreleaser]
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 512Mi
|
||||
cpu: 1
|
||||
limits:
|
||||
memory: 2Gi
|
||||
cpu: 2
|
||||
@@ -38,7 +38,7 @@ rpm: rpm-package
|
||||
# goreleaser drives the build and the nfpm packaging in one pass, so packaging
|
||||
# an already-built binary is not a separate step.
|
||||
rpm-package:
|
||||
goreleaser release --snapshot --clean
|
||||
GOTOOLCHAIN=auto go run github.com/goreleaser/goreleaser/v2@v2.20.2 release --snapshot --clean --skip=sign
|
||||
|
||||
# Bump helpers — read the latest semver tag and create the next one.
|
||||
# If no tag exists yet, start from v0.0.0.
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user