This commit is contained in:
병준 박 2025-04-25 19:54:48 +00:00
parent 17e434dd92
commit 98cfd0a0b2
3 changed files with 27 additions and 16 deletions

View File

@ -16,7 +16,7 @@ spec:
- name: specDomain
type: string
default: ""
- name: specVersion
- name: version
description: Rust crate version
type: string
default: "0.0.0"
@ -69,7 +69,7 @@ spec:
-g $(params.generator) \
-o $OUTPUT \
--additional-properties=packageName="${PACKAGE_NAME}" \
--additional-properties=packageVersion=$(params.specVersion) \
--additional-properties=packageVersion=$(params.version) \
--additional-properties=publish=true \
--additional-properties=disableValidator=false \
"${GENERATOR_OPTIONS[@]}" # 배열 확장

View File

@ -8,13 +8,12 @@ spec:
type: string
description: context directory
default: ""
- name: ref
type: string
description: Full Git ref string (e.g., refs/tags/v0.2.0)
- name: specDomain
type: string
default: ""
- name: specVersion
description: Rust crate version
type: string
default: "0.0.0"
workspaces:
- name: base
description: Git-cloned source code
@ -30,16 +29,24 @@ spec:
value: /workspace/base/$(params.context)/home
script: |
set -e
echo "🔍 Extracting tag from Git ref..."
FULL_REF="$(params.ref)"
TAG_FROM_REF=$(basename "$FULL_REF") # → 0.2.0
OPENAPI_FILE="specs/$(params.specDomain)/openapi.yaml"
EXPECTED_VERSION="$(params.specVersion)"
ACTUAL_VERSION=$(yq '.info.version' "$OPENAPI_FILE")
echo "📄 Reading version from openapi.yaml of ${OPENAPI_FILE}..."
VERSION=$(yq '.info.version' "$OPENAPI_FILE")
TAG_FROM_OPENAPI="${VERSION}"
echo "Expected: $EXPECTED_VERSION"
echo "Actual: $ACTUAL_VERSION"
echo "🔁 Comparing Git tag and workspace version:"
echo " - Git ref tag: $TAG_FROM_REF"
echo " - openapi version: $TAG_FROM_OPENAPI"
if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then
echo "❌ Version mismatch! Expected: $EXPECTED_VERSION, Actual: $ACTUAL_VERSION"
if [ "$TAG_FROM_REF" != "$TAG_FROM_OPENAPI" ]; then
echo "❌ Mismatch! Git tag and openapi version are not the same."
exit 1
fi
echo "✅ Tag and version match: $ACTUAL_VERSION"
echo -n "$ACTUAL_VERSION" > /tekton/results/version
echo "✅ Tag and version match: $VERSION"
echo -n "$VERSION" > /tekton/results/version

View File

@ -28,6 +28,11 @@ spec:
default: "main"
description: Git branch to operate on
- name: version
description: Rust crate version
type: string
default: "0.0.0"
- name: workspaceName
type: string
description: Nx workspace project name to lint and test
@ -94,8 +99,7 @@ spec:
npx nx import "${SOURCE_PATH}" "${TARGET_PROJECT}"
# Version sync
SRC_VERSION=$(grep '^version =' "${SOURCE_PATH}/Cargo.toml" | cut -d'"' -f2)
sed -i.bak "s/^version = .*/version = \"${SRC_VERSION}\"/" "${TARGET_PATH}/Cargo.toml"
sed -i.bak "s/^version = .*/version = \"$(params.version)\"/" "${TARGET_PATH}/Cargo.toml"
rm -f "${TARGET_PATH}/Cargo.toml.bak"
done