Skip to content

Commit

Permalink
Add script for making a release
Browse files Browse the repository at this point in the history
  • Loading branch information
matsbov committed Aug 24, 2023
1 parent 5feb295 commit 01807a8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ run:

run-docker:
docker compose up --detach

release:
@./sbdi/make-release.sh
9 changes: 9 additions & 0 deletions sbdi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ Build and run in Docker (using Tomcat):
```
make run-docker
```

Make a release. This will create a new tag and push it. A new Docker container will be built on Github.
```
mats@xps-13:~/src/biodiversitydata-se/dashboard (master *)$ make release
Current version: v2.0.1. Enter the new version (or press Enter for v2.0.2):
Updating to version v2.0.2
Tag v2.0.2 created and pushed.
```
33 changes: 33 additions & 0 deletions sbdi/make-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Get the last GitHub tag version
last_tag=$(git describe --tags --abbrev=0)

major=$(echo "$last_tag" | cut -d. -f1)
minor=$(echo "$last_tag" | cut -d. -f2)
patch=$(echo "$last_tag" | cut -d. -f3)

new_patch=$((patch + 1))

echo
read -p "Current version: $last_tag. Enter the new version (or press Enter for $major.$minor.$new_patch): " new_version_input

if [ -z "$new_version_input" ]; then
new_version="$major.$minor.$new_patch"
else
new_version="$new_version_input"
fi

# Validate the new version format (assuming it follows semantic versioning)
if ! [[ "$new_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Please use semantic versioning (e.g., v1.2.3)."
exit 1
fi

echo "Updating to version $new_version"

# Create a new tag
git tag "$new_version"
git push origin "$new_version"

echo "Tag $new_version created and pushed."

0 comments on commit 01807a8

Please sign in to comment.