Skip to content

Commit

Permalink
Add script for updating prod tag (#1473)
Browse files Browse the repository at this point in the history
This is currently available for copy/paste from release documentation
but does not take into account that remote names vary.
  • Loading branch information
hqpho authored Dec 4, 2024
1 parent b5d6d7c commit 4f60d5a
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions scripts/update_prod_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Updates the prod tag to point to the latest semantically versioned release.

set -e
set -o pipefail

# Find the remote associated with the main repo
upstream_remote=$(git remote -v | grep "datacommonsorg" | cut -f1 | uniq)
if [ -z "$upstream_remote" ]; then
echo "No remote found with 'datacommonsorg' in its URL."
exit 1
fi
echo "Remote for main repo is '${upstream_remote}'".

# Check out the latest release tag
# The latest tag will start with the letter "v", example "v2.0.12".
# sort -V uses "version" sorting to get the latest tag
git fetch "$upstream_remote" --tags
latest_release_tag=$(git tag -l "v*" | sort -V | tail -n1)
git checkout "$latest_release_tag"

# Confirm before updating the tag
read -r -p "Update the mixer prod tag to point to '$latest_release_tag'? [y/n] " response
if [[ ! "$response" =~ ^[Yy]$ ]]; then
echo "Aborting..."
exit 0
fi

# Delete the old prod tag locally and remotely
git tag -d prod
git push "$upstream_remote" :refs/tags/prod

# Tag release as prod & push to github
git tag prod
git push "$upstream_remote" prod

0 comments on commit 4f60d5a

Please sign in to comment.