Skip to content

Commit

Permalink
Move some more stuff from libosdp
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Feb 17, 2024
1 parent bbab042 commit e2a52a4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: sidcha
2 changes: 1 addition & 1 deletion .github/workflows/publish-crate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching Rust-v*, i.e. Rust-v1.0
- '*'

jobs:
publish:
Expand Down
67 changes: 67 additions & 0 deletions scripts/make-release.sh
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

0 comments on commit e2a52a4

Please sign in to comment.