Skip to content

Commit

Permalink
conf: tag annotaton via script
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Sep 1, 2023
1 parent 82c5e19 commit 9950f64
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
37 changes: 37 additions & 0 deletions bin/annotate-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Annotate a tag from Github
# FAQ: Github releases create annotated (not lightweight) tags
# SEE: https://github.com/orgs/community/discussions/4924

# Whether string is a valid SemVer version
is_valid_semver() {
local version=$1
# SemVer regex pattern (simplified for illustration)
local semver_pattern="^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
[[ $version =~ $semver_pattern ]]
}

# Is argument (string) provided?
if [ $# -ne 1 ]; then
echo "Usage: $0 <version_string>"
exit 1
fi

# Capture arguments
version_string=$1

# Is string a valid SemVer version?
if ! is_valid_semver "$version_string"; then
echo "Error: Invalid SemVer format. Please provide a valid version string like '3.11.6' or 'v3.12.0-beta.3' or 'v3.6.0-8-gd1dbcab'."
exit 1
fi

# Annotate the tag
git pull
git checkout "$version_string"
git tag -d "$version_string"
git tag -a "$version_string" -m "chore: $version_string"

# Report success
echo "Annotated tag \"$version_string\"."
11 changes: 5 additions & 6 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ Only appointed team members may release versions.
1. Commit NPM build output.
1. Merge pull request.
1. Create release and tag on GitHub.
1. Replace Github's unannotated tag with an annotated one:
- `git pull`
- `git checkout vN.N.N`
- `git tag -d vN.N.N`
- `git tag -a vN.N.N -m "____: vN.N.N"`
- `git push --tags --force`
1. Annotate Github's tag:\
`bin/annotate-tag.sh vN.N.N`\
(where `N.N.N` is the version tag)
1. Overwrite remote tag with annotated one:\
`git push --tags --force`

0 comments on commit 9950f64

Please sign in to comment.