Skip to content

Commit

Permalink
fix: add version check in publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
Diegiwg committed Jun 26, 2024
1 parent 0befa71 commit fb52ece
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.4
v1.3.5
11 changes: 10 additions & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

set -e

# Get the last version in repository
CURRENT_VERSION=$(git describe --abbrev=0 --tags)

# Get the declared version in .version file
VERSION=$(cat .version)

# Check if versions are equal
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
echo "Versions are equal. Nothing to publish"
exit 0
fi

# Tidy the repository
go mod tidy

Expand All @@ -19,7 +28,7 @@ GOPROXY=proxy.golang.org go list -m github.com/Diegiwg/tt@"$VERSION"

# Test if the version was published
echo "Getting the version from https://pkg.go.dev/github.com/Diegiwg/tt@$VERSION..."
OK=$(curl -o /dev/null -s -w "%{http_code}\n" https://pkg.go.dev/github.com/Diegiwg/tt@"$VERSION")
OK=$(curl -o /dev/null -X 'POST' -s -w "%{http_code}\n" https://pkg.go.dev/github.com/Diegiwg/tt@"$VERSION")

if [ "$OK" = "200" ]; then
echo "Version $VERSION was published"
Expand Down

0 comments on commit fb52ece

Please sign in to comment.