Files
clean-architecture-backend-…/.gitea/workflows/release.yml
T
DongHyeonka 3272faeb38
pr / done (pull_request) Successful in 11m34s
docs(ci): 단계·job 설명을 지금 workflow와 빌드에 맞춘다
round9 확인 리뷰가 CI 파일의 설명이 실제와 다른 곳을 짚었다.

- verify.sh 머리 표: PR 단계 job 이름이 `gradle`이다. 실제는 `done`.
- build.gradle: JMH가 「세 leaf」에 있다고 하지만 지금은 플러그인을
  쓰는 leaf가 정한다. verifyFeatureScaffold는 「leaf 다섯 중첩
  빌드」라고 하지만 그 안의 architectureCheck가 모든 leaf의
  architecture lane을 부른다.
- release.yml: `release` job 주석은 「ci를 다시 돌리지 않는다」인데
  뒤의 job들은 ci가 이미 돈 시험 일부를 다시 돈다. 그 이유(문서가
  job id로 부르는 릴리스 증거이고, 이미지 job이 모두를 needs로 받아
  같은 run·같은 커밋에서 통과한 뒤 publish한다)를 적었다. job은 그대로다.
- gates.md 2절: redis-topology 줄을 desktop에서 그대로 돌리라고 하지만
  스크립트 안 ./gradlew는 daemon을 남긴다. desktop에서는
  GRADLE_OPTS=-Dorg.gradle.daemon=false를 붙이라고 적었다. 스크립트에
  --no-daemon을 넣지 않은 이유: CI는 한 job의 step 11개가 daemon을
  다시 쓴다.
- redis-sdk compose README: cache-redis 칸에 필수 클래스가 둘뿐이다.
  build.gradle의 standalone·cluster 목록 다섯으로 맞췄다.
- template-vs-consumer.md: object-storage-aws를 nightly job으로 적었다.
  실제는 손으로 실행하고 입력 run_protected_aws를 켤 때만 돈다. 최상위
  항목을 더하면 「AGENTS.md 지도를 함께 고친다」고 했지만 지도는 루트
  목록을 두지 않고 check-repo-layout.py를 가리킨다. src/ 최상위 폴더일
  때만 지도의 src/ 줄을 고친다고 적었다.

동작 변경 없음: workflow는 주석만, 스크립트는 머리 주석만 바꿨다.

검증: scripts/verify.sh docs(노트북) rc=0.

Refs: round9 확인 리뷰(r9-be wave1-r4 「넘길 것」)
2026-11-12 21:36:05 +09:00

293 lines
15 KiB
YAML

# Release stage: produce the deployable artifact. One workflow, because there is one deployable unit,
# `app-bootstrap`; CI does not deploy (docs/ci-cd/boundary.md).
#
# A `vMAJOR.MINOR.PATCH` tag runs everything and publishes the image to this Gitea's container
# registry, signed by digest. A manual run is the rehearsal: every gate, the image build, the SBOM
# and the image scan, and nothing that publishes or signs.
#
# Secrets (repository settings, created by the owner): PACKAGE_TOKEN, a personal access token with
# package read/write (the job token cannot publish packages); COSIGN_PRIVATE_KEY and COSIGN_PASSWORD,
# the release signing key pair's private half and its password (owner decision 2026-11-07: Gitea
# issues no OIDC token, so keyless signing cannot run here).
name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
# Never cancel a release in flight. A half-pushed manifest is worse than a slow one.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
TESTCONTAINERS_REUSE_ENABLE: "false"
jobs:
# The tag-only checks: release provenance and the public path baseline. Not `ci` again: a tag is
# cut from a main commit the pull-request and main stages already ran on.
#
# The jobs after this one do run again some tests `ci` ran (the web, WebSocket and HTTP client
# suites, the fileserver checks, three persistence-jpa tests). They are the release evidence the
# support documents name by job id, and the image job needs every one of them, so each of them
# passed in this run on this commit before anything is published.
release:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: ./gradlew :releaseCheck
# The web, WebSocket and HTTP client release lanes, one Gradle run with --continue. They were three
# jobs, and each paid checkout, JDK, Gradle start and the compile of the modules it shares with the
# others (about two minutes of a 2.5-minute job, release run 62); --continue still reports every
# lane that fails. The JPA and fileserver jobs below stay jobs of their own: their names and the
# PostgreSQL matrix are what JpaReleaseRenderingTest and the fileserver support matrix read.
# webAdvancedTest selects tests `:web-advanced:test` already runs; what it adds is failing closed
# when its tag selects nothing.
stable-release-gates:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: >-
./gradlew --continue
:adapter:inbound:web:systemTest
:adapter:inbound:web:webJettyCompatTest
:adapter:inbound:web-advanced:webAdvancedTest
:adapter:inbound:websocket:test
:adapter:inbound:websocket:systemTest
:adapter:inbound:websocket:websocketJettyTest
:adapter:inbound:websocket:websocketNginxTest
:adapter:inbound:websocket:websocketTransportQualificationTest
:adapter:outbound:httpclient:test
:adapter:outbound:httpclient:spring62ApiSurfaceScan
:adapter:outbound:httpclient:spring70CompatibilityTest
:adapter:outbound:httpclient:httpClientStableContractTest
:adapter:outbound:httpclient:httpClientSecurityTest
:adapter:outbound:httpclient:httpClientFailureInjectionTest
:adapter:outbound:httpclient:httpClientPerformanceTest
httpclient-documentation:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- run: python3 scripts/verify-httpclient-docs.py
# One job per Stable PostgreSQL major: one job for three majors was one job for one major, because
# the platform starts only the first selected version. persistence-jpa's
# release/release-registry.json owns the gate tasks (jpaReleaseQualification depends on them), and
# JpaReleaseRenderingTest holds this list to the registry's Stable majors. The image job needs this
# job, so every major has passed, in this run and on this commit, before anything is published.
jpa-release-gate:
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
postgresql: ["16", "17", "18"]
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: ./gradlew jpaReleaseQualification -Pjpa.matrix.versions=${{ matrix.postgresql }}
jpa-registry-and-docs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: >-
./gradlew :adapter:outbound:persistence-jpa:test
--tests '*JpaReleaseManifestTest' --tests '*JpaReleaseRenderingTest' --tests '*JpaReadinessRegistryTest'
# Fileserver certification. docs/fileserver/support-matrix.md names these job ids as evidence, and
# FileserverDocumentationCoverageTest fails when a named job is missing.
fileserver-full-verification:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: >-
./gradlew
:application-fileserver:check
:adapter:inbound:web-fileserver:check
:adapter:outbound:fileserver:check
:adapter:outbound:persistence-fileserver:check
:composition:fileserver-platform:check
fileserver-documentation-gate:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: ./gradlew :composition:fileserver-platform:test --tests '*FileserverDocumentationCoverageTest'
fileserver-sensitive-telemetry-scan:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
- uses: ./.gitea/actions/setup-java-gradle
- run: ./gradlew :application-fileserver:test --tests '*FileserverObservabilityTest'
# Build, inventory and scan the image; on a tag also push it. It waits on every evidence job:
# `needs` does not reach across workflows, so a gate in another file could still be running.
app-image-release:
needs:
- release
- stable-release-gates
- httpclient-documentation
- jpa-release-gate
- jpa-registry-and-docs
- fileserver-full-verification
- fileserver-documentation-gate
- fileserver-sensitive-telemetry-scan
outputs:
pinned_reference: ${{ steps.push.outputs.pinned_reference }}
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2
# The tag is the release identity; a tag that does not parse stops the release here. A manual
# run is a rehearsal and builds version 0.0.0, which no release tag names.
- name: Resolve the release coordinates
run: |
set -euo pipefail
if [ "${GITHUB_REF_TYPE}" = tag ]; then
if [[ ! "${GITHUB_REF_NAME}" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
echo "release: the tag must be vMAJOR.MINOR.PATCH with no suffix; got '${GITHUB_REF_NAME}'" >&2
exit 1
fi
version="${BASH_REMATCH[1]}"
else
version=0.0.0
fi
registry="${GITHUB_SERVER_URL#https://}"
repository="${registry}/$(printf '%s' "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')/caskeleton"
{
echo "REGISTRY=${registry}"
echo "RELEASE_VERSION=${version}"
echo "BUILD_VERSION=${version}+${GITHUB_SHA}"
echo "IMAGE_REPOSITORY=${repository}"
echo "SOURCE_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
} >> "${GITHUB_ENV}"
echo "release: ${GITHUB_REF_NAME} -> ${repository}:${version} and :sha-${GITHUB_SHA}"
# SOURCE_DATE_EPOCH is the commit time, so the image config `created` field and every history
# timestamp are a function of the commit. It does not rewrite file mtimes inside the layers;
# byte-identical layers would need the containerd image store.
- name: Build the release image
run: |
set -euo pipefail
SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)"
export SOURCE_DATE_EPOCH
DOCKER_BUILDKIT=1 docker build \
--file Dockerfile \
--tag "${IMAGE_REPOSITORY}:${RELEASE_VERSION}" \
--tag "${IMAGE_REPOSITORY}:sha-${GITHUB_SHA}" \
--build-arg RELEASE_VERSION="${RELEASE_VERSION}" \
--build-arg BUILD_VERSION="${BUILD_VERSION}" \
--build-arg GIT_SHA="${GITHUB_SHA}" \
--build-arg SOURCE_URL="${SOURCE_URL}" \
--label org.opencontainers.image.created="$(git log -1 --format=%cI)" \
.
# The SBOM is printed and kept in the log before the blocking scan, so the inventory of an image
# that is refused still exists. A vulnerable image is never pushed: the push comes after.
# The image scan also reads Trivy's Java index (952 MB), the bulk of this job's download time.
- uses: ./.gitea/actions/trivy-db-cache
with:
java-db: "true"
- name: Inventory and scan the release image
run: |
set -euo pipefail
bash scripts/ci/trivy-scan.sh image "${IMAGE_REPOSITORY}:${RELEASE_VERSION}"
echo "release: SBOM image-sbom.cdx.json, $(wc -c < image-sbom.cdx.json) bytes, sha256 $(sha256sum image-sbom.cdx.json | cut -d' ' -f1)"
# Two tags, one digest. The digest recorded here is what a GitOps manifest pins; the tags exist
# so a person can find it.
- name: Push the release and revision tags
id: push
if: ${{ github.ref_type == 'tag' }}
env:
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
run: |
set -euo pipefail
[ -n "${PACKAGE_TOKEN}" ] || { echo "release: PACKAGE_TOKEN is not set" >&2; exit 1; }
printf '%s' "${PACKAGE_TOKEN}" | docker login "${REGISTRY}" --username "${GITHUB_REPOSITORY_OWNER}" --password-stdin
docker push "${IMAGE_REPOSITORY}:${RELEASE_VERSION}"
docker push "${IMAGE_REPOSITORY}:sha-${GITHUB_SHA}"
pinned="$(docker image inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "${IMAGE_REPOSITORY}:${RELEASE_VERSION}" \
| awk -v prefix="${IMAGE_REPOSITORY}@sha256:" 'index($0, prefix) == 1 { print; exit }')"
[ -n "${pinned}" ] || { echo "release: no registry digest for ${IMAGE_REPOSITORY} after push" >&2; exit 1; }
echo "pinned_reference=${pinned}" >> "${GITHUB_OUTPUT}"
echo "release: pin this in the GitOps manifest: ${pinned}"
# Signs the pushed digest with the release key pair and verifies the signature before the release
# counts as done, so a signature a cluster would reject fails here rather than at admission. A job
# of its own, so the private key exists only in a job that checks nothing out and builds nothing.
#
# The tag condition is on each step, not on the job. This Gitea (1.27) leaves a job that has both
# `needs` and `if` Blocked (main.yml `performance` says how that was found), so a manual run never
# finished: the job waited forever. With no job `if` it starts after app-image-release, and on a
# manual run every step is skipped.
app-image-signing:
needs:
- app-image-release
runs-on: ubuntu-latest
timeout-minutes: 30
env:
PINNED_REFERENCE: ${{ needs.app-image-release.outputs.pinned_reference }}
steps:
# A pinned release binary with an asserted SHA-256, no action: the cosign-linux-{amd64,arm64}
# lines of the official v3.1.3 cosign_checksums.txt. The checksum file is fetched again and must
# still carry the pinned line, so a re-published asset fails the job.
- name: Install pinned cosign
if: ${{ github.ref_type == 'tag' }}
run: |
set -euo pipefail
readonly COSIGN_VERSION='3.1.3'
readonly COSIGN_SHA256_AMD64='4629c757b7618056f8ddd7e2625ae9fdd94c0372a65049520bc7d9df9efc7f71'
readonly COSIGN_SHA256_ARM64='c5d324e091826b0d7a78eb16fef316450b4eb9aaec045611c08ba06f5e73220a'
readonly DOWNLOAD_BASE_URL="https://github.com/sigstore/cosign/releases/download/v${COSIGN_VERSION}"
case "$(uname -m)" in
x86_64) asset='cosign-linux-amd64'; expected="${COSIGN_SHA256_AMD64}" ;;
aarch64) asset='cosign-linux-arm64'; expected="${COSIGN_SHA256_ARM64}" ;;
*) echo "release: unsupported architecture $(uname -m)" >&2; exit 1 ;;
esac
install_dir="${RUNNER_TEMP}/cosign-${COSIGN_VERSION}"
mkdir -p "${install_dir}"
curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
"${DOWNLOAD_BASE_URL}/cosign_checksums.txt" --output "${RUNNER_TEMP}/cosign_checksums.txt"
grep -qxF "${expected} ${asset}" "${RUNNER_TEMP}/cosign_checksums.txt" \
|| { echo "release: cosign_checksums.txt no longer lists the pinned ${asset} hash" >&2; exit 1; }
curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
"${DOWNLOAD_BASE_URL}/${asset}" --output "${install_dir}/cosign"
printf '%s %s\n' "${expected}" "${install_dir}/cosign" | sha256sum -c -
chmod 0755 "${install_dir}/cosign"
echo "${install_dir}" >> "${GITHUB_PATH}"
- name: Sign the image digest and verify the signature
if: ${{ github.ref_type == 'tag' }}
env:
PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
run: |
set -euo pipefail
[[ "${PINNED_REFERENCE}" =~ ^[a-z0-9.-]+/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$ ]] \
|| { echo "release: app-image-release handed over no digest reference; got '${PINNED_REFERENCE}'" >&2; exit 1; }
[ -n "${COSIGN_PRIVATE_KEY}" ] || { echo "release: COSIGN_PRIVATE_KEY is not set" >&2; exit 1; }
printf '%s' "${PACKAGE_TOKEN}" | cosign login "${PINNED_REFERENCE%%/*}" --username "${GITHUB_REPOSITORY_OWNER}" --password-stdin
cosign sign --yes --key env://COSIGN_PRIVATE_KEY "${PINNED_REFERENCE}"
cosign public-key --key env://COSIGN_PRIVATE_KEY > "${RUNNER_TEMP}/cosign.pub"
cosign verify --key "${RUNNER_TEMP}/cosign.pub" "${PINNED_REFERENCE}" > /dev/null
echo "release: signed and verified ${PINNED_REFERENCE} with:"
cat "${RUNNER_TEMP}/cosign.pub"