Skip to content

Commit 1b5ad2e

Browse files
authored
Initial commit of version scripts (#1033)
This PR drops in a copy of our usual version-bump scripts (previously used in Pyk, currently in all semantics projects). We want this versioning information to make CI improvements to K a bit more ergonomic. It explicitly does not run the scripts in CI yet, because we rely on `package/version` existing in the PR base branch. I will follow this PR up with a matching one that correctly bumps the version on PRs.
1 parent 347ca27 commit 1b5ad2e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

package/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

package/version.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -xeuo pipefail
4+
5+
notif() { echo "== $@" >&2 ; }
6+
fatal() { echo "[FATAL] $@" ; exit 1 ; }
7+
8+
version_file="package/version"
9+
10+
version_bump() {
11+
local version release_commit version_major version_minor version_patch new_version current_version current_version_major current_version_minor current_version_patch
12+
version="$1" ; shift
13+
version_major="$(echo ${version} | cut --delimiter '.' --field 1)"
14+
version_minor="$(echo ${version} | cut --delimiter '.' --field 2)"
15+
version_patch="$(echo ${version} | cut --delimiter '.' --field 3)"
16+
current_version="$(cat ${version_file})"
17+
current_version_major="$(echo ${current_version} | cut --delimiter '.' --field 1)"
18+
current_version_minor="$(echo ${current_version} | cut --delimiter '.' --field 2)"
19+
current_version_patch="$(echo ${current_version} | cut --delimiter '.' --field 3)"
20+
new_version="${version}"
21+
if [[ "${version_major}" == "${current_version_major}" ]] && [[ "${version_minor}" == "${current_version_minor}" ]]; then
22+
new_version="${version_major}.${version_minor}.$((version_patch + 1))"
23+
fi
24+
echo "${new_version}" > "${version_file}"
25+
notif "Version: ${new_version}"
26+
}
27+
28+
version_sub() {
29+
local version
30+
version="$(cat $version_file)"
31+
}
32+
33+
version_command="$1" ; shift
34+
35+
case "${version_command}" in
36+
bump) version_bump "$@" ;;
37+
sub) version_sub "$@" ;;
38+
*) fatal "No command: ${version_command}" ;;
39+
esac

0 commit comments

Comments
 (0)