Skip to content

Commit

Permalink
#3 ✨ add release script to help ease multi-phase build process
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ryan-ashcraft committed Nov 15, 2023
1 parent 555858d commit f532bc5
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 7 deletions.
2 changes: 1 addition & 1 deletion baton-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.technologybrewery.baton</groupId>
<artifactId>baton</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</parent>

<name>Baton::Maven Plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-migration-configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.technologybrewery.baton</groupId>
<artifactId>examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</parent>

<name>Baton::Examples::Configuration</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-projects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.technologybrewery.baton</groupId>
<artifactId>examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</parent>

<name>Baton::Examples::Projects</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/example-projects/toml-file-update/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.technologybrewery.baton</groupId>
<artifactId>example-projects</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</parent>

<name>Baton::Examples::TOML File Update</name>
Expand Down
6 changes: 5 additions & 1 deletion examples/example-projects/toml-file-update/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "toml-file-update"
version = "0.1.0.dev"
version = "0.1.0"
description = ""
authors = ["Ryan Ashcraft <ryan.ashcraft@codifyiq.com>"]
readme = "README.md"
Expand All @@ -11,6 +11,10 @@ python = "^3.11"

[tool.poetry.group.monorepo.dependencies]


[tool.poetry.group.dev.dependencies]
behave = "^1.2.6"

[tool.poetry.dev-dependencies]
black = "^23.10.1"

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.technologybrewery.baton</groupId>
<artifactId>baton</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
</parent>

<name>Baton::Examples</name>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<groupId>org.technologybrewery.baton</groupId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.0</version>
<artifactId>baton</artifactId>
<packaging>pom</packaging>

Expand Down
77 changes: 77 additions & 0 deletions release-baton.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

#This script requires two input parameter, 1)target release version 2)next development version.
#To run the script, enter a command like this: ./release-baton.sh <target-release-version> <next-development-version>

#After the script is executed, navigate to github to create a PR to merge your release branch
#and validate that the released version of baton-maven-plugin may be found in Maven Central

echo "////////////////////////////////////////////"
echo "//"
echo "// Use this script to run a release for Baton"
echo "//"
echo "////////////////////////////////////////////"

echo "//////////// Check out a release branch ////////////"
git checkout -b $1-release

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to check out release branch!'; exit 1
fi

echo "/////////// Check there are no uncommitted local changes ///////////"
mvn scm:check-local-modification

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Uncommitted local changes detected!'; exit 1
fi

echo "/////////// Update POM versions to the target release version ///////////"
mvn versions:set -DnewVersion=$1 -DgenerateBackupPoms=false

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to update POM versions to the target release version'; exit 1
fi

echo "/////////// Rebuild Baton modules (1) ///////////"
mvn clean install -Pbootstrap -Dmaven.build.cache.enabled=false && mvn clean install -pl :example-migration-configuration -Dmaven.build.cache.enabled=false && mvn clean initialize -Dmaven.build.cache.enabled=false

if [[ "$?" -ne 0 ]] ; then
echo 'Rebuilding Baton (1) failed!'; exit 1
fi

echo "/////////// Commit all changes that reflect the target release version and create a tag ///////////"
mvn scm:checkin -Dmessage=":memo: Prepare release baton-$1"
mvn scm:tag -Dtag=baton-$1

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to commit changes and create a tag!'; exit 1
fi

echo "/////////// Deploy Baton to Maven Central ///////////"
mvn deploy -P ossrh-release -Dmaven.build.cache.enabled=false

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to deploy Baton to Maven Central!'; exit 1
fi

echo "/////////// Update POM versions to the next development version ///////////"
mvn versions:set -DnewVersion=$2 -DgenerateBackupPoms=false

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to update POM versions to the next development version!'; exit 1
fi

echo "/////////// Rebuild Baton modules (2) ///////////"
mvn clean install -Pbootstrap && mvn clean install -pl :example-migration-configuration && mvn clean initialize

if [[ "$?" -ne 0 ]] ; then
echo 'Rebuilding Baton (2) failed!'; exit 1
fi

echo "/////////// Commit all changes that reflect the next development iteration///////////"
mvn scm:checkin -Dmessage="Prepare for next development iteration"

if [[ "$?" -ne 0 ]] ; then
echo 'Process failed! Unable to commit changes for the next development iteration!'; exit 1
fi

0 comments on commit f532bc5

Please sign in to comment.