Skip to content

Commit

Permalink
package/version: add versioning files (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehildenb authored Feb 19, 2024
1 parent ec9c36c commit d88cc6f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions package/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
40 changes: 40 additions & 0 deletions package/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

set -xeuo pipefail

notif() { echo "== $@" >&2 ; }
fatal() { echo "[FATAL] $@" ; exit 1 ; }

version_file="package/version"

version_bump() {
local version release_commit version_major version_minor version_patch new_version current_version current_version_major current_version_minor current_version_patch
version="$1" ; shift
version_major="$(echo ${version} | cut --delimiter '.' --field 1)"
version_minor="$(echo ${version} | cut --delimiter '.' --field 2)"
version_patch="$(echo ${version} | cut --delimiter '.' --field 3)"
current_version="$(cat ${version_file})"
current_version_major="$(echo ${current_version} | cut --delimiter '.' --field 1)"
current_version_minor="$(echo ${current_version} | cut --delimiter '.' --field 2)"
current_version_patch="$(echo ${current_version} | cut --delimiter '.' --field 3)"
new_version="${version}"
if [[ "${version_major}" == "${current_version_major}" ]] && [[ "${version_minor}" == "${current_version_minor}" ]]; then
new_version="${version_major}.${version_minor}.$((version_patch + 1))"
fi
echo "${new_version}" > "${version_file}"
notif "Version: ${new_version}"
}

version_sub() {
local version
version="$(cat $version_file)"
sed --in-place 's/^version = ".*"$/version = "'${version}'"/' pykwasm/pyproject.toml
}

version_command="$1" ; shift

case "${version_command}" in
bump) version_bump "$@" ;;
sub) version_sub "$@" ;;
*) fatal "No command: ${version_command}" ;;
esac

0 comments on commit d88cc6f

Please sign in to comment.