Skip to content
Merged
39 changes: 1 addition & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,44 +175,7 @@ initiate a build and deploy with the service framework:

Opening a PR against either branch will also create an ephemeral staging environment, and a site link will be added to the PR comment section.

The release process can be managed with git flow, initialized with the default settings. To bring forth a production release, pull local `develop` and `main` to latest, and follow these steps:

- Identify the latest release

Use [CalVer](https://calver.org/) versioning.
If the latest release is `2024.2.3` then the next release will be `2024.2.4` if it's still february, otherwise `2024.3.1` or whatever month/year it happens to be when you are runnign releases.

```bash
git tag | sort
```

- Start a release

```bash
git flow release start X.Y.Z
```

- Bump the version number in `package.json` and check it in

```bash
git status # check staging area is clean
git add package.json
git commit -m "X.Y.Z"
```

- Publish the release

```bash
git flow release publish X.Y.Z
```

- Finish and push the release branch
- When prompted, keep default commit messages
- Use `X.Y.Z` as the tag message

```bash
git flow release finish -p X.Y.Z
```
The release process is orchestrated with the `scripts/release` script.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pc-datacatalog",
"version": "2025.4.3",
"version": "2025.7.1",
"private": true,
"proxy": "http://api:7071/",
"dependencies": {
Expand Down
294 changes: 294 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
#!/bin/bash

set -e

function usage() {
echo -n "Usage: $(basename "$0") [OPTIONS]
Automate the release process using git flow and CalVer versioning.

This script will:
1. Checkout the develop branch
2. Identify the latest release tag
3. Calculate the next CalVer version (or use provided version)
4. Start a git flow release
5. Bump version in package.json
6. Publish and finish the release

Options:
--version VERSION: Specify a custom version instead of auto-calculating (format: YYYY.M.P)
--help: Display this help message
"
}

function error() {
echo "Error: $1" >&2
exit 1
}

function confirm() {
local prompt="$1"
local response
read -r -p "$prompt [y/N]: " response
case "$response" in
[yY][eE][sS]|[yY])
return 0
;;
*)
return 1
;;
esac
}

function check_git_flow() {
if ! command -v git-flow &> /dev/null; then
error "git-flow is not installed. Please install it first: https://github.com/nvie/gitflow/wiki/Installation"
fi

# Check for macOS and ensure GNU getopt is available
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v /usr/local/opt/gnu-getopt/bin/getopt &> /dev/null && ! command -v /opt/homebrew/opt/gnu-getopt/bin/getopt &> /dev/null; then
error "On macOS, git-flow requires GNU getopt. Install it with: brew install gnu-getopt"
fi
fi
}

function check_gh_cli() {
if ! command -v gh &> /dev/null; then
error "GitHub CLI (gh) is not installed. Please install it first: https://cli.github.com/"
fi
}

function check_clean_working_directory() {
if [[ -n $(git status --porcelain) ]]; then
error "Working directory is not clean. Please commit or stash your changes first."
fi
}

function get_latest_tag() {
git tag | sort -V | tail -n 1
}

function calculate_next_version() {
local latest_tag="$1"
local current_year=$(date +%Y)
local current_month=$(date +%-m)

if [[ -z "$latest_tag" ]]; then
echo "${current_year}.${current_month}.1"
return
fi

# Parse the latest tag (format: YYYY.M.P)
if [[ $latest_tag =~ ^([0-9]{4})\.([0-9]+)\.([0-9]+)$ ]]; then
local tag_year="${BASH_REMATCH[1]}"
local tag_month="${BASH_REMATCH[2]}"
local tag_patch="${BASH_REMATCH[3]}"

# If same year and month, increment patch
if [[ "$tag_year" == "$current_year" ]] && [[ "$tag_month" == "$current_month" ]]; then
echo "${current_year}.${current_month}.$((tag_patch + 1))"
else
# New month or year, reset patch to 1
echo "${current_year}.${current_month}.1"
fi
else
error "Latest tag '$latest_tag' does not follow CalVer format (YYYY.M.P)"
fi
}

function update_package_json_version() {
local version="$1"

if [[ ! -f "package.json" ]]; then
error "package.json not found in current directory"
fi

# Use Node.js to update the version in package.json
if command -v node &> /dev/null; then
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '$version';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
else
# Fallback to sed if node is not available
sed -i.bak 's/"version": ".*"/"version": "'$version'"/' package.json && rm package.json.bak
fi

echo "Updated package.json to version $version"
}

function run_release() {
local custom_version="$1"

echo "=== Planetary Computer Data Catalog Release Process ==="
echo ""

# Check prerequisites
check_git_flow
check_gh_cli
check_clean_working_directory

# Step 1: Checkout develop branch
echo "Step 1: Checking out develop branch..."
git checkout develop
echo "Pulling latest changes from origin..."
git pull origin develop
echo ""

# Step 2: Identify latest release
echo "Step 2: Identifying latest release..."
latest_tag=$(get_latest_tag)
if [[ -z "$latest_tag" ]]; then
echo "No existing tags found."
else
echo "Latest release tag: $latest_tag"
fi
echo ""

# Step 3: Determine next version
if [[ -n "$custom_version" ]]; then
echo "Step 3: Using custom version..."
# Validate custom version format
if [[ ! $custom_version =~ ^([0-9]{4})\.([0-9]+)\.([0-9]+)$ ]]; then
error "Custom version '$custom_version' does not follow CalVer format (YYYY.M.P)"
fi
next_version="$custom_version"
echo "Using version: $next_version"
else
echo "Step 3: Calculating next version..."
next_version=$(calculate_next_version "$latest_tag")
echo "Next version will be: $next_version"
fi
echo ""

if ! confirm "Continue with version $next_version?"; then
echo "Release cancelled."
exit 0
fi
echo ""

# Step 4: Start git flow release
echo "Step 4: Starting git flow release..."
if ! git flow release start "$next_version" 2>&1; then
# Check if there's an existing release branch
existing_release=$(git branch | grep "release/" | sed 's/^[ *]*//' | head -n 1)
if [[ -n "$existing_release" ]]; then
echo ""
echo "Found existing release branch: $existing_release"
if confirm "Delete the existing release branch and continue?"; then
echo "Deleting $existing_release..."
git checkout develop
git branch -D "$existing_release" || error "Failed to delete local branch $existing_release"

# Try to delete remote branch if it exists
if git ls-remote --heads origin "$existing_release" | grep -q "$existing_release"; then
echo "Deleting remote branch..."
git push origin --delete "$existing_release" 2>/dev/null || echo "Note: Could not delete remote branch (may not exist or lack permissions)"
fi

echo "Retrying release start..."
if ! git flow release start "$next_version"; then
error "Failed to start git flow release after cleanup"
fi
else
error "Cannot proceed with existing release branch. Please finish or delete it manually."
fi
else
error "Failed to start git flow release"
fi
fi
echo ""

# Step 5: Bump version in package.json
echo "Step 5: Updating version in package.json..."
update_package_json_version "$next_version"

if ! confirm "Version updated in package.json. Review the changes and continue?"; then
echo "Release cancelled. You are still on the release branch."
echo "To abort, run: git flow release delete $next_version"
exit 0
fi

git add package.json
git commit -m "$next_version"
echo ""

# Step 6: Publish release
echo "Step 6: Publishing release..."
if ! confirm "Publish release branch to origin?"; then
echo "Release not published. You are still on the release branch."
echo "To publish later, run: git flow release publish $next_version"
echo "To abort, run: git flow release delete $next_version"
exit 0
fi

if ! git flow release publish "$next_version"; then
error "Failed to publish git flow release"
fi
echo ""

# Step 7: Create pull request to main
echo "Step 7: Creating pull request to main..."
echo ""

if ! confirm "Ready to create a pull request from release/$next_version to main?"; then
echo "Pull request not created. The release branch has been published."
echo "To create PR later, run: gh pr create --base main --head release/$next_version"
exit 0
fi

# Create PR to main branch
echo "Creating pull request..."
if ! gh pr create \
--base main \
--head "release/$next_version" \
--title "Release $next_version" \
--body "Automated release $next_version

This release includes all changes from the develop branch.

After merging:
- GitHub Actions will build and deploy to production
- The release will be tagged as $next_version
- Changes will need to be merged back to develop"; then
error "Failed to create pull request. You may need to check your GitHub CLI authentication."
fi

echo ""
echo "=== Pull request for release $next_version created successfully! ==="
echo ""
echo "Next steps:"
echo " 1. Review and merge the PR to main"
echo " 2. GitHub Actions will build and deploy to production"
echo " 3. After merge, the release will be tagged as $next_version"
echo " 4. Merge main back to develop to complete the release cycle"
echo ""
echo "View the PR with: gh pr view"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
custom_version=""

while [[ $# -gt 0 ]]; do
case "$1" in
--help)
usage
exit 0
;;
--version)
if [[ -z "${2:-}" ]]; then
error "Missing value for --version option"
fi
custom_version="$2"
shift 2
;;
*)
error "Unknown option: $1"
;;
esac
done

run_release "$custom_version"
fi
29 changes: 28 additions & 1 deletion src/config/datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ conus404:
- title: Example Notebook
src: conus404-example.html
launch: datasets/conus404/conus404-example.ipynb

cop-dem-glo-30:
category: DEMs
headerImg: ./images/cop-dem-glo-30-hero.png
Expand Down Expand Up @@ -553,6 +553,33 @@ landsat-c2-l2:
landsat-8-c2-l2:
isHidden: true

met-office-global-deterministic-whole-atmosphere:
isHidden: true

met-office-global-deterministic-height:
isHidden: true

met-office-global-deterministic-pressure:
isHidden: true

met-office-global-deterministic-near-surface:
isHidden: true

met-office-uk-deterministic-height:
isHidden: true

met-office-uk-deterministic-whole-atmosphere:
isHidden: true

met-office-uk-deterministic-pressure:
isHidden: true

met-office-uk-deterministic-whole-atmosphere-:
isHidden: true

met-office-uk-deterministic-near-surface:
isHidden: true

modis-09A1-061:
category: Imagery
headerImg: ./images/modis-09a1-hero.png
Expand Down
Loading