Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Adjusting docs vs regular version update files
  • Loading branch information
jimschubert committed Jun 5, 2019
commit 78e39d9121172a8d23c9b68bea045388ab4b9959
5 changes: 5 additions & 0 deletions bin/utils/release/release_version_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ declare -a xml_files=("modules/openapi-generator-cli/pom.xml"
"modules/openapi-generator-maven-plugin/pom.xml"
"modules/openapi-generator-online/pom.xml"
"modules/openapi-generator/pom.xml"
"modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml"
"modules/openapi-generator-maven-plugin/examples/java-client.xml"
"modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"modules/openapi-generator-maven-plugin/examples/non-java.xml"
"samples/meta-codegen/lib/pom.xml"
"pom.xml")

# These files should wrap target version replacement blocks with # RELEASE_VERSION and # /RELEASE_VERSION
declare -a properties_files=(
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
)

${cwd}/bump.sh -f ${version} -i ${inc} ${xml_files[@]}
Expand Down
125 changes: 87 additions & 38 deletions bin/utils/release/release_version_update_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,95 @@
# limitations under the License.
#

if [[ "$1" != "" ]]; then
FROM="$1"
else
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1 3.0.2"
exit 1;
declare cwd=$(cd $(dirname "${BASH_SOURCE}") && pwd)

USAGE="
USAGE: $0 [version] target

This script will convert the specified version in DOC target files to the 'target'
where target is one of:

major
minor
build

or an explicitly defined version number.

NOTE:

Files prepped by this script should never target SNAPSHOT, as the docs should refer to release artifacts.
If intending to update to/from snapshots, please add target files to release_version_update.sh instead.

EXAMPLES:

Update build version (1.0.0 -> 1.0.1)
$0 build
Update minor version (1.2.3 -> 1.3.0)
$0 minor
Update major version (1.2.3 -> 2.0.0)
$0 major
"

declare version=$(ruby -r rexml/document -e 'include REXML;
p XPath.first(Document.new($stdin), "/project/version/text()")' < ${cwd}/../../../pom.xml)

declare target="${2:-build}"
declare inc=""
declare next_version=""
declare ags=""

if [[ -z "$1" ]]; then
echo "Missing argument." >&2
echo -e "$USAGE" >&2
exit 1
fi

if [[ "$2" != "" ]]; then
TO="$2"
# Get version number we're changing
case $1 in
--help|-h)
echo -e "$USAGE" >&2
exit 1
;;
*)
version="$1"
;;
esac

# Get the target…
case ${target} in
major|minor|build)
inc="$target"
;;
snapshot)
echo -e "Files prepped by this script should never target SNAPSHOT, as the docs should refer to release artifacts.
If intending to update to/from snapshots, please add target files to release_version_update.sh instead.
" >&2
exit 1
;;
*)
next_version="$target"
;;
esac

ags="-f ${version}"

if [[ -n "${next_version}" ]];then
echo "Release preparation: Moving from $version to ${next_version}."
ags="$ags -t ${next_version}"
else
echo "Missing argument. Usage e.g.: ./bin/utils/release_version_update.sh 3.0.1 3.0.2"
exit 1;
echo "Release preparation: Moving from $version to next $inc version."
ags="$ags -i ${inc}"
fi

echo "Release preparation: replacing $FROM with $TO in different files"

declare -a files=("modules/openapi-generator-maven-plugin/README.md"
"modules/openapi-generator-maven-plugin/examples/multi-module/java-client/pom.xml"
"modules/openapi-generator-maven-plugin/examples/java-client.xml"
"modules/openapi-generator-maven-plugin/examples/non-java-invalid-spec.xml"
"modules/openapi-generator-maven-plugin/examples/non-java.xml"
"modules/openapi-generator-gradle-plugin/README.adoc"
"modules/openapi-generator-gradle-plugin/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties"
"modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle"
"modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
"README.md")

sedi () {
# Cross-platform version of sed -i that works both on Mac and Linux
sed --version >/dev/null 2>&1 && sed -i -e "$@" || sed -i "" "$@"
}

for filename in "${files[@]}"; do
# e.g. sed -i '' "s/3.0.1-SNAPSHOT/3.0.1/g" CI/pom.xml.bash
#echo "Running command: sed -i '' "s/$FROM/$TO/g" $filename"
if sedi "s/$FROM/$TO/g" $filename; then
echo "Updated $filename successfully!"
else
echo "ERROR: Failed to update $filename with the following command"
echo "sed -i '' \"s/$FROM/$TO/g\" $filename"
fi
done
declare -a xml_files=(
"modules/openapi-generator-maven-plugin/README.md"
"modules/openapi-generator-gradle-plugin/samples/local-spec/README.md"
"README.md"
)

declare -a commented_files=(
"modules/openapi-generator-gradle-plugin/README.adoc"
)

${cwd}/bump.sh ${ags} ${xml_files[@]}
${cwd}/bump.sh ${ags} -s '# RELEASE_VERSION' -e '# \/RELEASE_VERSION' ${commented_files[@]}
5 changes: 4 additions & 1 deletion modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ compileJava.dependsOn tasks.openApiGenerate
====

== Plugin Setup

//# RELEASE_VERSION
[source,groovy]
----
buildscript {
Expand All @@ -54,6 +54,7 @@ buildscript {

apply plugin: 'org.openapi.generator'
----
//# /RELEASE_VERSION

[NOTE]
====
Expand Down Expand Up @@ -591,6 +592,7 @@ Android Studio may experience a Windows-specific Guava dependency conflict with

As a workaround, you may force exclude conflicting Guava dependencies.

//# RELEASE_VERSION
```gradle
buildscript {
repositories {
Expand All @@ -612,5 +614,6 @@ configurations {
// …
apply plugin: 'org.openapi.generator'
```
//# /RELEASE_VERSION

See https://github.com/OpenAPITools/openapi-generator/issues/1818[OpenAPITools/openapi-generator#1818] for more details.
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
openApiGeneratorVersion=4.0.1
# RELEASE_VERSION
openApiGeneratorVersion=4.0.2-SNAPSHOT
# /RELEASE_VERSION
2 changes: 2 additions & 0 deletions modules/openapi-generator-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.1</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
Expand Down
2 changes: 2 additions & 0 deletions modules/openapi-generator-maven-plugin/examples/non-java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>4.0.2-SNAPSHOT</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
Expand Down