Skip to content

Commit

Permalink
Fixing the release script (#10)
Browse files Browse the repository at this point in the history
* Fixing the release script

* Adding the automatic next version detection
  • Loading branch information
brahle authored Sep 8, 2023
1 parent 45ca33f commit 2670a86
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 10 deletions.
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,7 @@ virtualenv: ## Create a virtual environment.

.PHONY: release
release: ## Create a new tag for release.
@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
@echo "$${TAG}" > brds/VERSION
@$(ENV_PREFIX)gitchangelog > HISTORY.md
@git add brds/VERSION HISTORY.md
@git commit -m "release: version $${TAG} 🚀"
@echo "creating git tag : $${TAG}"
@git tag $${TAG}
@git push -u origin HEAD --tags
@echo "Github Actions will detect the new tag and release the new version."
./release.sh

.PHONY: docs
docs: ## Build the documentation.
Expand Down
34 changes: 34 additions & 0 deletions next_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Get the list of tags and sort them in version order
LATEST_TAG=$(git tag -l | sort -V | tail -n1)

# Split the tag into major, minor, and patch versions
IFS='.' read -ra ADDR <<< "$LATEST_TAG"
MAJOR=${ADDR[0]}
MINOR=${ADDR[1]}
PATCH=${ADDR[2]}

# Decide which part to increment based on the passed argument
case "$1" in
--major)
MAJOR=$((MAJOR+1))
MINOR=0
PATCH=0
;;
--minor)
MINOR=$((MINOR+1))
PATCH=0
;;
--patch)
PATCH=$((PATCH+1))
;;
*)
# By default increment minor version
MINOR=$((MINOR+1))
PATCH=0
;;
esac

# Print the next version
echo "$MAJOR.$MINOR.$PATCH"
28 changes: 28 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Display warning
echo "WARNING: This operation will create a version tag and push to GitHub"

# Get the next version
TAG=$(./next_version.sh "$@")

# Display the version
echo "Releasing version '${TAG}'"

# Write the version to a file
echo "${TAG}" > brds/VERSION

# Generate changelog and commit the changes (assuming ENV_PREFIX is set in your environment)
${ENV_PREFIX}gitchangelog > HISTORY.md

# Add files and commit
git add brds/VERSION HISTORY.md
git commit -m "release: version ${TAG} 🚀"

# Create git tag and push
echo "creating git tag : ${TAG}"
git tag ${TAG}
git push -u origin HEAD --tags

# Notification
echo "Github Actions will detect the new tag and release the new version."

0 comments on commit 2670a86

Please sign in to comment.