Skip to content

Commit

Permalink
Update README.md; Add release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Nov 29, 2024
1 parent d1cd78b commit 3cf6dbb
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
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
```
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# commons-ip-cits-siard

Tool and Java Library to support creation and validation of E-ARK SIP following CITS SIARD specification
A Command line interface (CLI) and Java Library to support creation and validation of E-ARK SIP following CITS SIARD specification

[![GitHub latest release](https://img.shields.io/github/v/release/keeps/commons-ip-cits-siard?sort=semver&color=informational)](https://github.com/keeps/commons-ip-cits-siard/releases/latest)
![GitHub downloads](https://img.shields.io/github/downloads/keeps/commons-ip-cits-siard/total)
[![GitHub contributors](https://img.shields.io/github/contributors/keeps/commons-ip-cits-siard)](https://github.com/keeps/commons-ip-cits-siard/graphs/contributors)
![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/keeps/commons-ip-cits-siard)
<!-- {% comment %} -->
[![testing](https://github.com/keeps/commons-ip-cits-siard/actions/workflows/CI.yml/badge.svg)](https://github.com/keeps/commons-ip-cits-siard/actions/workflows/CI.yml?label=testing)
<!-- {% endcomment %}-->

> [!WARNING]
> Currently being developed
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 3cf6dbb

Please sign in to comment.