Skip to content

Commit 8f5d871

Browse files
committed
feat: add publish script for tagging and pushing versions
1 parent 784ad53 commit 8f5d871

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "shaka"
3-
version = "0.0.3"
43
edition = "2024"
5-
description = "Generate shell aliases and functions from YAML/JSONC config files"
6-
license = "MIT"
4+
version = "0.0.3"
75
readme = "README.md"
6+
license = "MIT"
7+
description = "Generate shell aliases and functions from YAML/JSONC config files"
88

99
[dependencies]
1010
indexmap = "2"

publish.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
version="$(awk -F '"' '/^version[[:space:]]*=/{print $2; exit}' Cargo.toml)"
5+
6+
if [ -z "$version" ]; then
7+
printf 'Could not read version from Cargo.toml\n' >&2
8+
exit 1
9+
fi
10+
11+
tag="v$version"
12+
13+
local_exists=false
14+
remote_exists=false
15+
16+
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
17+
local_exists=true
18+
fi
19+
20+
if git ls-remote --tags origin "refs/tags/$tag" | grep -q .; then
21+
remote_exists=true
22+
fi
23+
24+
if [ "$local_exists" = true ] || [ "$remote_exists" = true ]; then
25+
printf 'Tag %s already exists.\n' "$tag"
26+
read -r -p "Delete and recreate tag $tag? [y/N]: " answer
27+
28+
case "$answer" in
29+
y | Y | yes | YES)
30+
;;
31+
*)
32+
printf 'Cancelled.\n'
33+
exit 1
34+
;;
35+
esac
36+
37+
if [ "$local_exists" = true ]; then
38+
git tag -d "$tag"
39+
fi
40+
41+
if [ "$remote_exists" = true ]; then
42+
git push origin ":refs/tags/$tag"
43+
fi
44+
fi
45+
46+
git tag "$tag"
47+
git push origin "$tag"
48+
49+
printf 'Published %s\n' "$tag"

0 commit comments

Comments
 (0)