-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: sidcha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024 Siddharth Chandrasekaran <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
usage() { | ||
cat >&2<<---- | ||
LibOSDP release helper | ||
OPTIONS: | ||
-c, --component Compoenent to release (can be one of libosdp, libosdp-sys, osdpctl) | ||
--patch Release version bump type: patch (default) | ||
--major Release version bump type: major | ||
--minor Release version bump type: minor | ||
-h, --help Print this help | ||
--- | ||
} | ||
|
||
function caro_inc_version() { | ||
dir=$1 | ||
inc=$2 | ||
perl -pi -se ' | ||
if (/^version = "(\d+)\.(\d+)\.(\d+)"$/) { | ||
$maj=$1; $min=$2; $pat=$3; | ||
if ($major) { $maj+=1; $min=0; $pat=0; } | ||
if ($minor) { $min+=1; $pat=0; } | ||
$pat+=1 if $patch; | ||
$_="version = \"$maj.$min.$pat\"\n" | ||
}' -- -$inc $dir/Cargo.toml | ||
} | ||
|
||
function do_cargo_release() { | ||
crate=$1 | ||
inc=$2 | ||
caro_inc_version $crate $inc | ||
version=$(perl -ne 'print $1 if (/^version = "(.+)"$/)' $dir/Cargo.toml) | ||
git add $dir/Cargo.toml && | ||
git commit -s -m "$crate: Release v$version" && | ||
git tag "$crate-v$version" -a -m "Release $version" | ||
} | ||
|
||
function do_release() { | ||
case $1 in | ||
libosdp-sys) do_cargo_release "libosdp-sys" $2 ;; | ||
libosdp) do_cargo_release "libosdp" $2 ;; | ||
osdpctl) do_cargo_release "osdpctl" $2 ;; | ||
esac | ||
} | ||
|
||
INC="patch" | ||
COMPONENT="libosdp" | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
-c|--componenet) COMPONENT=$2; shift;; | ||
--patch) INC="patch";; | ||
--major) INC="major";; | ||
--minor) INC="minor";; | ||
-h|--help) usage; exit 0;; | ||
*) echo -e "Unknown option $1\n"; usage; exit 1;; | ||
esac | ||
shift | ||
done | ||
|
||
do_release $COMPONENT $INC | ||
|