From ffe67bb05f2abcf294b2b4d831dab3cb8f0eadd4 Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Thu, 17 Nov 2022 15:14:53 +0000 Subject: [PATCH] Fix event types in schema Add a new tool to control event versions in the schema and spec. Fix the event versions in schema and spec. Signed-off-by: Andrea Frittoli --- continuous-deployment-pipeline-events.md | 16 +-- schemas/artifactpackaged.json | 5 +- schemas/artifactpublished.json | 5 +- schemas/branchcreated.json | 5 +- schemas/branchdeleted.json | 5 +- schemas/buildfinished.json | 5 +- schemas/buildqueued.json | 5 +- schemas/buildstarted.json | 5 +- schemas/changeabandoned.json | 5 +- schemas/changecreated.json | 5 +- schemas/changemerged.json | 5 +- schemas/changereviewed.json | 5 +- schemas/changeupdated.json | 5 +- schemas/environmentcreated.json | 5 +- schemas/environmentdeleted.json | 5 +- schemas/environmentmodified.json | 5 +- schemas/pipelinerunfinished.json | 5 +- schemas/pipelinerunqueued.json | 5 +- schemas/pipelinerunstarted.json | 5 +- schemas/repositorycreated.json | 5 +- schemas/repositorydeleted.json | 5 +- schemas/repositorymodified.json | 5 +- schemas/servicedeployed.json | 5 +- schemas/servicepublished.json | 5 +- schemas/serviceremoved.json | 5 +- schemas/servicerolledback.json | 5 +- schemas/serviceupgraded.json | 5 +- schemas/taskrunfinished.json | 5 +- schemas/taskrunstarted.json | 5 +- schemas/testcasefinished.json | 5 +- schemas/testcasequeued.json | 5 +- schemas/testcasestarted.json | 5 +- schemas/testsuitefinished.json | 5 +- schemas/testsuitestarted.json | 5 +- tools/event-version.sh | 166 +++++++++++++++++++++++ tools/spec-release.sh | 6 +- version.txt | 2 +- 37 files changed, 310 insertions(+), 45 deletions(-) create mode 100755 tools/event-version.sh diff --git a/continuous-deployment-pipeline-events.md b/continuous-deployment-pipeline-events.md index 6cfadd90..4799b013 100644 --- a/continuous-deployment-pipeline-events.md +++ b/continuous-deployment-pipeline-events.md @@ -47,7 +47,7 @@ A `service` can represent for example a binary that is running, a daemon, an app This event represents an environment that has been created. Such an environment can be used to deploy services in. -- Event Type: __`dev.cdevents.environment.created.0.1`__ +- Event Type: __`dev.cdevents.environment.created.0.1.0`__ - Predicate: created - Subject: [`environment`](#environment) @@ -62,7 +62,7 @@ This event represents an environment that has been created. Such an environment This event represents an environment that has been modified. -- Event Type: __`dev.cdevents.environment.modified.0.1`__ +- Event Type: __`dev.cdevents.environment.modified.0.1.0`__ - Predicate: modified - Subject: [`environment`](#environment) @@ -77,7 +77,7 @@ This event represents an environment that has been modified. This event represents an environment that has been deleted.``` -- Event Type: __`dev.cdevents.environment.deleted.0.1`__ +- Event Type: __`dev.cdevents.environment.deleted.0.1.0`__ - Predicate: deleted - Subject: [`environment`](#environment) @@ -91,7 +91,7 @@ This event represents an environment that has been deleted.``` This event represents a new instance of a service that has been deployed -- Event Type: __`dev.cdevents.service.deployed.0.1`__ +- Event Type: __`dev.cdevents.service.deployed.0.1.0`__ - Predicate: deployed - Subject: [`service`](#service) @@ -105,7 +105,7 @@ This event represents a new instance of a service that has been deployed This event represents an existing instance of a service that has been upgraded to a new version -- Event Type: __`dev.cdevents.service.upgraded.0.1`__ +- Event Type: __`dev.cdevents.service.upgraded.0.1.0`__ - Predicate: upgraded - Subject: [`service`](#service) @@ -119,7 +119,7 @@ This event represents an existing instance of a service that has been upgraded t This event represents an existing instance of a service that has been rolled back to a previous version -- Event Type: __`dev.cdevents.service.rolledback.0.1`__ +- Event Type: __`dev.cdevents.service.rolledback.0.1.0`__ - Predicate: rolledback - Subject: [`service`](#service) @@ -133,7 +133,7 @@ This event represents an existing instance of a service that has been rolled bac This event represents the removal of a previously deployed service instance and is thus not longer present in the specified environment -- Event Type: __`dev.cdevents.service.removed.0.1`__ +- Event Type: __`dev.cdevents.service.removed.0.1.0`__ - Predicate: removed - Subject: [`service`](#service) @@ -146,7 +146,7 @@ This event represents the removal of a previously deployed service instance and This event represents an existing instance of a service that has an accessible URL for users to interact with it. This event can be used to let other tools know that the service is ready and also available for consumption. -- Event Type: __`dev.cdevents.service.published.0.1`__ +- Event Type: __`dev.cdevents.service.published.0.1.0`__ - Predicate: published - Subject: [`service`](#service) diff --git a/schemas/artifactpackaged.json b/schemas/artifactpackaged.json index c3f3dd5b..320078b0 100644 --- a/schemas/artifactpackaged.json +++ b/schemas/artifactpackaged.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.artifact.packaged.0.1.0" + ], + "default": "dev.cdevents.artifact.packaged.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/artifactpublished.json b/schemas/artifactpublished.json index 5eb31a2d..c3a748c0 100644 --- a/schemas/artifactpublished.json +++ b/schemas/artifactpublished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.artifact.published.0.1.0" + ], + "default": "dev.cdevents.artifact.published.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/branchcreated.json b/schemas/branchcreated.json index a6bc194b..ca81af46 100644 --- a/schemas/branchcreated.json +++ b/schemas/branchcreated.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.branch.created.0.1.1" + ], + "default": "dev.cdevents.branch.created.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/branchdeleted.json b/schemas/branchdeleted.json index 623f7e9d..c5aa1b14 100644 --- a/schemas/branchdeleted.json +++ b/schemas/branchdeleted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.branch.deleted.0.1.1" + ], + "default": "dev.cdevents.branch.deleted.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/buildfinished.json b/schemas/buildfinished.json index 64b4e0d7..b9d5c68f 100644 --- a/schemas/buildfinished.json +++ b/schemas/buildfinished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.build.finished.0.1.0" + ], + "default": "dev.cdevents.build.finished.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/buildqueued.json b/schemas/buildqueued.json index 03c1deed..54c6f140 100644 --- a/schemas/buildqueued.json +++ b/schemas/buildqueued.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.build.queued.0.1.0" + ], + "default": "dev.cdevents.build.queued.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/buildstarted.json b/schemas/buildstarted.json index cd9e48a9..3af85d01 100644 --- a/schemas/buildstarted.json +++ b/schemas/buildstarted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.build.started.0.1.0" + ], + "default": "dev.cdevents.build.started.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/changeabandoned.json b/schemas/changeabandoned.json index 40ea7f17..0d1ca3fe 100644 --- a/schemas/changeabandoned.json +++ b/schemas/changeabandoned.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.change.abandoned.0.1.1" + ], + "default": "dev.cdevents.change.abandoned.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/changecreated.json b/schemas/changecreated.json index 1311baba..5c138629 100644 --- a/schemas/changecreated.json +++ b/schemas/changecreated.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.change.created.0.1.1" + ], + "default": "dev.cdevents.change.created.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/changemerged.json b/schemas/changemerged.json index 03cab5a4..1a767f8b 100644 --- a/schemas/changemerged.json +++ b/schemas/changemerged.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.change.merged.0.1.1" + ], + "default": "dev.cdevents.change.merged.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/changereviewed.json b/schemas/changereviewed.json index 2b8aba40..5b8ef692 100644 --- a/schemas/changereviewed.json +++ b/schemas/changereviewed.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.change.reviewed.0.1.1" + ], + "default": "dev.cdevents.change.reviewed.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/changeupdated.json b/schemas/changeupdated.json index 488e0ffb..e92e2318 100644 --- a/schemas/changeupdated.json +++ b/schemas/changeupdated.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.change.updated.0.1.1" + ], + "default": "dev.cdevents.change.updated.0.1.1" }, "timestamp": { "type": "string", diff --git a/schemas/environmentcreated.json b/schemas/environmentcreated.json index 241d25b2..853adaad 100644 --- a/schemas/environmentcreated.json +++ b/schemas/environmentcreated.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.environment.created.0.1.0" + ], + "default": "dev.cdevents.environment.created.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/environmentdeleted.json b/schemas/environmentdeleted.json index fc0dbd98..36bbb484 100644 --- a/schemas/environmentdeleted.json +++ b/schemas/environmentdeleted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.environment.deleted.0.1.0" + ], + "default": "dev.cdevents.environment.deleted.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/environmentmodified.json b/schemas/environmentmodified.json index 0c181b72..42aaa709 100644 --- a/schemas/environmentmodified.json +++ b/schemas/environmentmodified.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.environment.modified.0.1.0" + ], + "default": "dev.cdevents.environment.modified.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/pipelinerunfinished.json b/schemas/pipelinerunfinished.json index 5ea85b33..1e4ec1d6 100644 --- a/schemas/pipelinerunfinished.json +++ b/schemas/pipelinerunfinished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.pipelinerun.finished.0.1.0" + ], + "default": "dev.cdevents.pipelinerun.finished.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/pipelinerunqueued.json b/schemas/pipelinerunqueued.json index 8823036c..fae92a87 100644 --- a/schemas/pipelinerunqueued.json +++ b/schemas/pipelinerunqueued.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.pipelinerun.queued.0.1.0" + ], + "default": "dev.cdevents.pipelinerun.queued.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/pipelinerunstarted.json b/schemas/pipelinerunstarted.json index 90f95f23..e3623631 100644 --- a/schemas/pipelinerunstarted.json +++ b/schemas/pipelinerunstarted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.pipelinerun.started.0.1.0" + ], + "default": "dev.cdevents.pipelinerun.started.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/repositorycreated.json b/schemas/repositorycreated.json index 16c98fd0..5eb78ebe 100644 --- a/schemas/repositorycreated.json +++ b/schemas/repositorycreated.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.repository.created.0.1.0" + ], + "default": "dev.cdevents.repository.created.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/repositorydeleted.json b/schemas/repositorydeleted.json index fb30132e..6ec291e6 100644 --- a/schemas/repositorydeleted.json +++ b/schemas/repositorydeleted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.repository.deleted.0.1.0" + ], + "default": "dev.cdevents.repository.deleted.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/repositorymodified.json b/schemas/repositorymodified.json index 4a67bfb7..ec883c7a 100644 --- a/schemas/repositorymodified.json +++ b/schemas/repositorymodified.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.repository.modified.0.1.0" + ], + "default": "dev.cdevents.repository.modified.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/servicedeployed.json b/schemas/servicedeployed.json index ac3a4075..5c4bd1ff 100644 --- a/schemas/servicedeployed.json +++ b/schemas/servicedeployed.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.service.deployed.0.1.0" + ], + "default": "dev.cdevents.service.deployed.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/servicepublished.json b/schemas/servicepublished.json index 24514d53..304e5e62 100644 --- a/schemas/servicepublished.json +++ b/schemas/servicepublished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.service.published.0.1.0" + ], + "default": "dev.cdevents.service.published.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/serviceremoved.json b/schemas/serviceremoved.json index 1dc84c1d..caab26ae 100644 --- a/schemas/serviceremoved.json +++ b/schemas/serviceremoved.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.service.removed.0.1.0" + ], + "default": "dev.cdevents.service.removed.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/servicerolledback.json b/schemas/servicerolledback.json index b439328d..430993bf 100644 --- a/schemas/servicerolledback.json +++ b/schemas/servicerolledback.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.service.rolledback.0.1.0" + ], + "default": "dev.cdevents.service.rolledback.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/serviceupgraded.json b/schemas/serviceupgraded.json index 56d27fbc..ba95fdc7 100644 --- a/schemas/serviceupgraded.json +++ b/schemas/serviceupgraded.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.service.upgraded.0.1.0" + ], + "default": "dev.cdevents.service.upgraded.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/taskrunfinished.json b/schemas/taskrunfinished.json index bdaa17d1..045ac803 100644 --- a/schemas/taskrunfinished.json +++ b/schemas/taskrunfinished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.taskrun.finished.0.1.0" + ], + "default": "dev.cdevents.taskrun.finished.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/taskrunstarted.json b/schemas/taskrunstarted.json index ae2f40ee..ecad1242 100644 --- a/schemas/taskrunstarted.json +++ b/schemas/taskrunstarted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.taskrun.started.0.1.0" + ], + "default": "dev.cdevents.taskrun.started.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/testcasefinished.json b/schemas/testcasefinished.json index cc8f9b67..3d262e79 100644 --- a/schemas/testcasefinished.json +++ b/schemas/testcasefinished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.testcase.finished.0.1.0" + ], + "default": "dev.cdevents.testcase.finished.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/testcasequeued.json b/schemas/testcasequeued.json index 6f87746e..d84b2fec 100644 --- a/schemas/testcasequeued.json +++ b/schemas/testcasequeued.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.testcase.queued.0.1.0" + ], + "default": "dev.cdevents.testcase.queued.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/testcasestarted.json b/schemas/testcasestarted.json index 29e846b7..57be7d3f 100644 --- a/schemas/testcasestarted.json +++ b/schemas/testcasestarted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.testcase.started.0.1.0" + ], + "default": "dev.cdevents.testcase.started.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/testsuitefinished.json b/schemas/testsuitefinished.json index fbac5858..4e808bd8 100644 --- a/schemas/testsuitefinished.json +++ b/schemas/testsuitefinished.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.testsuite.finished.0.1.0" + ], + "default": "dev.cdevents.testsuite.finished.0.1.0" }, "timestamp": { "type": "string", diff --git a/schemas/testsuitestarted.json b/schemas/testsuitestarted.json index 7078c822..83157a82 100644 --- a/schemas/testsuitestarted.json +++ b/schemas/testsuitestarted.json @@ -18,7 +18,10 @@ }, "type": { "type": "string", - "minLength": 1 + "enum": [ + "dev.cdevents.testsuite.started.0.1.0" + ], + "default": "dev.cdevents.testsuite.started.0.1.0" }, "timestamp": { "type": "string", diff --git a/tools/event-version.sh b/tools/event-version.sh new file mode 100755 index 00000000..15bfa7a0 --- /dev/null +++ b/tools/event-version.sh @@ -0,0 +1,166 @@ +#!/usr/bin/env bash + +# Copyright 2022 The CDEvents Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +function usage() { + cat < updates all event references from M.m.0 to M.m+1.0-draft + event-version.sh -u artifact.packaged -m -> updates all event references from M.m.0 to M+1.0.0-draft + event-version.sh -u artifact.packaged -e -> updates all event references from M.m.0-draft to M.m.0 + event-version.sh -u artifact.packaged -p -> updates all event references from M.m.p to M.m.p+1 + event-version.sh -u artifact.packaged -v 1.2.3 -> updates all event references to 1.2.3 +EOF +} + +set -o errexit +set -o nounset +set -o pipefail + +declare COMMAND INCREMENT VERSION NEW_VERSION EVENT_SUBJECT_PREDICATE +declare VERSION_FILE=version.txt + +START_COMMAND=start +END_COMMAND=end +PATCH_COMMAND=patch +VERSION_COMMAND=version + +# cd to the root path +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +cd "${ROOT}" + +while getopts ":smepv:u:" o; do + case "${o}" in + s) + COMMAND="${START_COMMAND}" + INCREMENT="minor" + ;; + m) + COMMAND="${START_COMMAND}" + INCREMENT="major" + ;; + e) + COMMAND="${END_COMMAND}" + ;; + p) + COMMAND="${PATCH_COMMAND}" + ;; + v) COMMAND="${VERSION_COMMAND}" + NEW_VERSION=${OPTARG} + ;; + u) EVENT_SUBJECT_PREDICATE=${OPTARG} + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [[ -z "${COMMAND}" || -z "${EVENT_SUBJECT_PREDICATE}" ]]; then + usage +fi + +if [ ! -f "$VERSION_FILE" ]; then + echo "Version file $VERSION_FILE not found" + exit 1 +fi + +# Evaluate the event subject.predicate +SPLIT_EVENT=(${EVENT_SUBJECT_PREDICATE//./ }) +SUBJECT=${SPLIT_EVENT[0]} +PREDICATE=${SPLIT_EVENT[1]} +SCHEMA_FILE="schemas/${SUBJECT}${PREDICATE}.json" + +# Evaluate the event version +OLD_VERSION=$(sed -n -e '/"default": "dev.cdevents.'${SUBJECT}'.'${PREDICATE}'./s/.*\.\([0-9]\.[0-9]\.[0-9]\)"/\1/p' ${SCHEMA_FILE}) +VERSION="${NEW_VERSION:-$OLD_VERSION}" +SPLIT_VERSION=(${VERSION//./ }) +MAJOR_VERSION=${SPLIT_VERSION[0]} +MINOR_VERSION=${SPLIT_VERSION[1]} +PATCH_VERSION_DRAFT=${SPLIT_VERSION[2]} +SPLIT_PATCH=(${PATCH_VERSION_DRAFT//-/ }) +PATCH_VERSION=${SPLIT_PATCH[0]} +DRAFT_VERSION="" +if [[ ${#SPLIT_PATCH[@]} > 1 ]]; then + DRAFT_VERSION="-${SPLIT_PATCH[1]}" +fi + +if [[ "${COMMAND}" == "${END_COMMAND}" ]]; then + if [[ -z ${DRAFT_VERSION} ]]; then + echo "Cannot end release ${VERSION}, must be in draft to end" + exit 1 + fi + DRAFT_VERSION="" +fi + +if [[ "${COMMAND}" == "${START_COMMAND}" ]]; then + if [[ -n ${DRAFT_VERSION} ]]; then + echo "Cannot start release ${VERSION}, already in ${DRAFT_VERSION}" + exit 1 + fi + PATCH_VERSION=0 + DRAFT_VERSION="-draft" + if [[ "${INCREMENT}" == "minor" ]]; then + MINOR_VERSION=$(( MINOR_VERSION + 1 )) + else + MAJOR_VERSION=$(( MAJOR_VERSION + 1 )) + MINOR_VERSION=0 + fi +fi + +if [[ "${COMMAND}" == "${PATCH_COMMAND}" ]]; then + if [[ -n ${DRAFT_VERSION} ]]; then + echo "Cannot start release ${VERSION}, already in ${DRAFT_VERSION}" + exit 1 + fi + PATCH_VERSION=$(( PATCH_VERSION + 1 )) +fi + +VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${DRAFT_VERSION}" + +# Replace the version in the schema IDs +sed -i ".backup" -e 's,"dev.cdevents.*","dev.cdevents.'${SUBJECT}'.'${PREDICATE}'.'${VERSION}'",g' "${SCHEMA_FILE}" + +# Update examples in docs +for doc in core source-code-version-control continuous-integration-pipeline-events continuous-deployment-pipeline-events; do + sed -i ".backup" -e 's,__`dev.cdevents.'${SUBJECT}'.'${PREDICATE}'.*`__,__`dev.cdevents.'${SUBJECT}'.'${PREDICATE}'.'${VERSION}'`__,g' "${doc}.md" +done + +# Cleanup backup files +find . -name '*.backup' | xargs rm diff --git a/tools/spec-release.sh b/tools/spec-release.sh index c65b0d5b..c0f9043b 100755 --- a/tools/spec-release.sh +++ b/tools/spec-release.sh @@ -37,11 +37,11 @@ Usage: -v Set the version to Major.minor.patch Examples: - spec-release.sh -s -> updates all release references on main to from M.m.0 to M.m+1.0-draft - spec-release.sh -m -> updates all release references on main to from M.m.0 to M+1.0.0-draft + spec-release.sh -s -> updates all release references on main fom from M.m.0 to M.m+1.0-draft + spec-release.sh -m -> updates all release references on main from from M.m.0 to M+1.0.0-draft spec-release.sh -e -> updates all release references on main from M.m.0-draft to M.m.0 spec-release.sh -p -> updates all release references on spec-vM.m from M.m.p to M.m.p+1 - spec-release.sh -v 1.2.3 -> updates all release references on 1.2.3 + spec-release.sh -v 1.2.3 -> updates all release references to 1.2.3 EOF } diff --git a/version.txt b/version.txt index d917d3e2..17e51c38 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.2 +0.1.1