From 56434641193ac45891372341b2e410f9e3aa3aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 10 May 2024 13:33:04 +0300 Subject: [PATCH] Hardcode version, add a release script Having thought about this more, I am semi-reverting fcd4d58c5532001b6ae2e28555318818c06e79ca in favor of hardcoding the version to the binary and a release script. --- Makefile | 2 +- btrfs-auto-snapshot | 4 +--- release | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 release diff --git a/Makefile b/Makefile index f22c944..59669db 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -FILES = btrfs-auto-snapshot +FILES = btrfs-auto-snapshot release .PHONY: lint lint: shfmt shellcheck diff --git a/btrfs-auto-snapshot b/btrfs-auto-snapshot index d791d17..c7ad077 100755 --- a/btrfs-auto-snapshot +++ b/btrfs-auto-snapshot @@ -24,9 +24,7 @@ set -euo pipefail #set -o functrace #set -o xtrace -# Define our version. Distributions may replace it with: -# sed -i 's/^\(BTRFS_AUTO_SNAPSHOT_VERSION\)=.*/\1=/' -BTRFS_AUTO_SNAPSHOT_VERSION=${BTRFS_AUTO_SNAPSHOT_VERSION:-unknown} +BTRFS_AUTO_SNAPSHOT_VERSION=v2.0.4+dev # Define various error codes ERR_SUCCESS=0 diff --git a/release b/release new file mode 100755 index 0000000..0c29504 --- /dev/null +++ b/release @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +log_run() +{ + echo >&2 "+ $*" + "$@" +} + +main() +{ + VERSION=$1 + if [[ ! $VERSION =~ ^v[0-9]\.[0-9]\.[0-9]$ ]]; then + echo >&2 "Invalid version. Expected v1.2.3 or so" + exit 1 + fi + + log_run sed -i'' 's/^\(BTRFS_AUTO_SNAPSHOT_VERSION\)=.*/\1='"$VERSION/" btrfs-auto-snapshot + log_run git add btrfs-auto-snapshot + log_run git commit -m "Release $VERSION" + log_run git tag "$VERSION" + log_run sed -i'' 's/^\(BTRFS_AUTO_SNAPSHOT_VERSION\)=.*/\1='"$VERSION+dev/" btrfs-auto-snapshot + log_run git add btrfs-auto-snapshot + log_run git commit -m "$VERSION+dev" + echo "You have tagged $VERSION. Now run the following:" + echo " git push origin master" + echo " git push origin $VERSION" +} + +main "$@"