diff --git a/base/tekton.dev/pipelines/okd-release-pipeline.yaml b/base/tekton.dev/pipelines/okd-release-pipeline.yaml index 48a856a..218a300 100644 --- a/base/tekton.dev/pipelines/okd-release-pipeline.yaml +++ b/base/tekton.dev/pipelines/okd-release-pipeline.yaml @@ -68,6 +68,8 @@ spec: value: okd-prow-sa-auth - name: target-release-stream value: $(params.target-release-stream) + - name: picked-release-name + value: $(tasks.pick-release.results.release-name) runAfter: - pick-release - name: verify-release diff --git a/base/tekton.dev/tasks/pick-target-release-name.yaml b/base/tekton.dev/tasks/pick-target-release-name.yaml index cc49e53..0377e1b 100644 --- a/base/tekton.dev/tasks/pick-target-release-name.yaml +++ b/base/tekton.dev/tasks/pick-target-release-name.yaml @@ -27,6 +27,9 @@ spec: - description: The release stream (e.g., 4-scos-stable) to target. name: target-release-stream type: string + - description: The name of the release picked for promotion + name: picked-release-name + type: string results: - name: target-release-name steps: @@ -55,6 +58,8 @@ spec: LAST_RELEASE_NAME="$(oc get is "$(params.release-imagestream)" -ojson| jq '.status.tags[-1].tag')" fi + OKD_VERSION=$(echo "$(params.picked-release-name)" | cut -d '-' -f 1) + LAST_OKD_VERSION=$(echo "$LAST_RELEASE_NAME" | cut -d '-' -f 1) # from the latest release name, construct the next release name regex='okd-scos-[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}' if [[ "$LAST_RELEASE_NAME" =~ (ec|okd-scos)\.([0-9]+) ]]; then @@ -62,24 +67,23 @@ spec: prefix=${BASH_REMATCH[1]} number=${BASH_REMATCH[2]} # Increment the number by 1 - incremented_number=$((number + 1)) - # Create the new string by replacing the old number with the new one - RELEASE_NAME="${LAST_RELEASE_NAME/$prefix.$number/$prefix.$incremented_number}" + if [[ "$OKD_VERSION" == "$LAST_OKD_VERSION" ]]; then + incremented_number=$((number + 1)) + else + incremented_number="0" + fi + # Create the new release string concatenating release number with okd-scos + RELEASE_NAME="$OKD_VERSION-$prefix.$incremented_number" printf "%s" "$RELEASE_NAME" > $(results.target-release-name.path) # Check for "okd-scos-" followed by a date timestamp elif [[ "$LAST_RELEASE_NAME" =~ $regex ]]; then - if [[ "$LAST_RELEASE_NAME" =~ ([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then - prefix="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}" - if [[ "$(params.release-imagestream)" == *"next" ]]; then - suffix="-okd-scos.ec.0" - else - suffix="-okd-scos.0" - fi - RELEASE_NAME="$prefix$suffix" - printf "%s" "$RELEASE_NAME" > $(results.target-release-name.path) + if [[ "$(params.release-imagestream)" == *"next" ]]; then + suffix="-okd-scos.ec.0" else - echo "Invalid release found!" + suffix="-okd-scos.0" fi + RELEASE_NAME="$OKD_VERSION$suffix" + printf "%s" "$RELEASE_NAME" > $(results.target-release-name.path) else echo "No previous release found!" fi diff --git a/environments/moc/pipelineruns/okd-release-next-pipelinerun.yaml b/environments/moc/pipelineruns/okd-release-next-pipelinerun.yaml index a0edf76..9fb9a83 100644 --- a/environments/moc/pipelineruns/okd-release-next-pipelinerun.yaml +++ b/environments/moc/pipelineruns/okd-release-next-pipelinerun.yaml @@ -25,7 +25,7 @@ spec: - name: release-mirror-pushspec value: quay.io/okd/scos-release - name: release-stream - value: 4.17.0-0.okd-scos + value: 4.18.0-0.okd-scos - name: target-release-stream value: 4-scos-next podTemplate: diff --git a/environments/moc/pipelineruns/okd-release-stable-pipelinerun.yaml b/environments/moc/pipelineruns/okd-release-stable-pipelinerun.yaml index e08cad1..b21a8e6 100644 --- a/environments/moc/pipelineruns/okd-release-stable-pipelinerun.yaml +++ b/environments/moc/pipelineruns/okd-release-stable-pipelinerun.yaml @@ -25,7 +25,7 @@ spec: - name: release-mirror-pushspec value: quay.io/okd/scos-release - name: release-stream - value: 4.16.0-0.okd-scos + value: 4.17.0-0.okd-scos - name: target-release-stream value: 4-scos-stable podTemplate: