diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..42bfc8a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: sidcha diff --git a/.github/workflows/publish-crate.yml b/.github/workflows/publish-crate.yml index 4932934..47bbe4b 100644 --- a/.github/workflows/publish-crate.yml +++ b/.github/workflows/publish-crate.yml @@ -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: diff --git a/scripts/make-release.sh b/scripts/make-release.sh new file mode 100755 index 0000000..437b088 --- /dev/null +++ b/scripts/make-release.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Copyright (c) 2024 Siddharth Chandrasekaran +# +# 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 +