Skip to content

Commit

Permalink
Add DEV_NOTES.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Nov 29, 2024
1 parent 8a03222 commit 4933d85
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
24 changes: 24 additions & 0 deletions DEV_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# DEV Notes

## How to release a new version

Before create a new version please update the CHANGELOG.md.

```bash
bash dev/scripts/release.sh 1.0.0
```

This will trigger a CI/CD pipeline where it will:

* Build & packaging the JDK library and CLI
* Build & deploy a docker image
* Create a draft GitHub release

After the pipeline ends please do the following step:

* Update the draft GitHub release
* Run the prepare next version script

```bash
bash dev/scripts/prepare-next-release.sh 1.1.0
```
29 changes: 29 additions & 0 deletions dev/scripts/prepare-next-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

REGEX="([0-9]+).([0-9]+).([0-9]+)"

if [[ $VERSION =~ $REGEX ]]; then
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
fi

MINOR=$((MINOR + 1))
BUILD="0"

SNAPSHOT_VERSION="${MAJOR}.${MINOR}.${BUILD}-SNAPSHOT"

cat <<EOF
################################
# Prepare for next version
################################
EOF

echo "Update version to $SNAPSHOT_VERSION"

mvn versions:set versions:commit -DnewVersion="$SNAPSHOT_VERSION"

git add pom.xml
git commit -S -m "Setting version $SNAPSHOT_VERSION"
git push
53 changes: 53 additions & 0 deletions dev/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

release() {

cat <<EOF
################################
# Release version
################################
EOF
RELEASE_VERSION=$1
RELEASE_TAG="$RELEASE_VERSION"
# Ensure all classes have license header
mvn license:format

# Updating Maven modules
mvn versions:set versions:commit -DnewVersion="$RELEASE_VERSION"

# Commit Maven version update
git add -u
git commit -S -m "Release version $RELEASE_VERSION"

# Create tag
git tag -s -a "$RELEASE_TAG" -m "Version $RELEASE_VERSION"

# Push tag
git push origin "$RELEASE_TAG"

return 0
}

# Check if an argument was passed
if [ $# -eq 0 ]; then
echo "No arguments provided."
echo "Usage: $0 <version>"
echo "Example: $0 2.5.0"
exit 1
else
regex="([0-9]+).([0-9]+).([0-9]+)"
if [[ $1 =~ $regex ]]; then
read -p "Did you update the CHANGELOG.md? (yes/no): " answer
case $answer in
[Yy]*) release "$1" ;;
[Nn]*)
echo "Update the CHANGELOG.md before release a new version"
exit 1
;;
*) echo "Please answer yes or no." ;;
esac
else
echo "Please provide a version that follows semantic versioning syntax"
exit 1
fi
fi

0 comments on commit 4933d85

Please sign in to comment.