-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automate many release steps (#429)
- Loading branch information
1 parent
32954d7
commit 37d8316
Showing
7 changed files
with
224 additions
and
1 deletion.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Overview | ||
|
||
… | ||
|
||
## Related | ||
|
||
<!-- | ||
- [CMD-XYZ](https://tacc-main.atlassian.net/browse/CMD-XYZ) | ||
- requires https://github.com/TACC/Core-CMS/pull/5 | ||
- required by https://github.com/TACC/Core-CMS-Resources/pull/117 | ||
-->… | ||
|
||
## Changes | ||
|
||
… | ||
|
||
## Testing | ||
|
||
1. | ||
|
||
## UI | ||
|
||
… | ||
|
||
<!-- | ||
## Notes | ||
… | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Function to prompt for confirmation | ||
confirm() { | ||
read -r -p "${1:-Are you sure?} [y/N] " response | ||
case "$response" in | ||
[yY][eE][sS]|[yY]) | ||
true | ||
;; | ||
*) | ||
false | ||
;; | ||
esac | ||
} | ||
|
||
# Function to check if command exists | ||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
set -e # Exit on any error | ||
|
||
# Source shared functions | ||
source "$(dirname "$0")/release-functions.sh" | ||
|
||
# Check required commands | ||
if ! command_exists npm; then | ||
echo "Error: npm is required but not installed" | ||
exit 1 | ||
fi | ||
if ! command_exists git; then | ||
echo "Error: git is required but not installed" | ||
exit 1 | ||
fi | ||
|
||
# Ensure working directory is clean except for CHANGELOG | ||
if [ -n "$(git status --porcelain | grep -v 'CHANGELOG.md')" ]; then | ||
echo "Error: Working directory has unexpected changes. Please commit or stash changes." | ||
exit 1 | ||
fi | ||
|
||
# Get current version and prompt for new version | ||
current_version=$(npm pkg get version | tr -d '"') | ||
read -r -p "Enter version number (current: $current_version, format: N.N.N): " version | ||
version_tag="v$version" | ||
|
||
# Name the branch | ||
branch_name="release/$version_tag" | ||
|
||
# Check if branch exists and handle accordingly | ||
if git rev-parse --verify "$branch_name" >/dev/null 2>&1 || \ | ||
git rev-parse --verify "origin/$branch_name" >/dev/null 2>&1; then | ||
echo "Branch '$branch_name' already exists." | ||
if confirm "Would you like to use the existing branch?"; then | ||
git checkout "$branch_name" | ||
git pull origin "$branch_name" 2>/dev/null || true # Pull if remote exists, ignore if it doesn't | ||
else | ||
echo "Release preparation cancelled." | ||
exit 0 | ||
fi | ||
else | ||
# Create new branch | ||
git checkout -b "$branch_name" | ||
fi | ||
|
||
# Confirm with user | ||
echo "This script will:" | ||
echo "1. Build CSS" | ||
echo "2. Update version" | ||
echo "3. Create release commit" | ||
echo "4. Push branch to remote" | ||
echo "5. Describe next steps" | ||
if ! confirm "Do you want to proceed?"; then | ||
echo "Release preparation cancelled." | ||
exit 0 | ||
fi | ||
|
||
# Build CSS | ||
echo "Building CSS..." | ||
npm run build:css | ||
|
||
# Check for substantial changes | ||
if [ -n "$(git status --porcelain | grep -v 'CHANGELOG.md' | grep -v '^.. dist/')" ]; then | ||
echo "Warning: Unexpected changes detected in build:" | ||
git status --porcelain | grep -v 'CHANGELOG.md' | grep -v '^.. dist/' | ||
echo "Please review changes and create an independent PR if necessary." | ||
if ! confirm "Continue anyway?"; then | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Prompt for CHANGELOG update | ||
echo "Please update CHANGELOG.md now." | ||
if ! confirm "Have you updated CHANGELOG.md?"; then | ||
exit 1 | ||
fi | ||
|
||
# Update version | ||
echo "Updating version..." | ||
npm version "$version_tag" --no-git-tag-version | ||
|
||
# Build again with new version | ||
echo "Building with new version..." | ||
npm run build:css | ||
|
||
# Commit changes | ||
git add . | ||
git commit -m "chore: $version_tag" | ||
|
||
# Push branch | ||
git push origin "$branch_name" | ||
|
||
echo "Branch pushed. Please create and merge PR for $branch_name" | ||
echo -e "After PR is merged, run:\n ./bin/release-publish.sh $version_tag" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
set -e # Exit on any error | ||
|
||
# Source shared functions | ||
source "$(dirname "$0")/release-functions.sh" | ||
|
||
if [ -z "$1" ]; then | ||
echo "Usage: $0 <version-tag>" | ||
echo "Example: $0 v1.2.3" | ||
exit 1 | ||
fi | ||
|
||
version_tag=$1 | ||
|
||
# Check npm login status | ||
if ! npm whoami >/dev/null 2>&1; then | ||
echo "Error: You are not logged in to npm." | ||
echo -e "Please login first with:\n npm login" | ||
echo -e "\nNote: When running npm login, you'll be prompted to visit a URL in your browser." | ||
echo "Make sure you're already logged into npmjs.com in your browser before starting." | ||
exit 1 | ||
fi | ||
|
||
# Ensure we're on main branch | ||
git checkout main | ||
git pull origin main | ||
|
||
# Check if version is already published | ||
if npm view "@tacc/core-styles@${version_tag#v}" >/dev/null 2>&1; then | ||
echo "Version ${version_tag#v} is already published to npm." | ||
if confirm "Skip npm publish step?"; then | ||
echo "Skipping npm publish..." | ||
else | ||
echo "Aborting to avoid version conflict." | ||
exit 1 | ||
fi | ||
else | ||
# Publish to npm | ||
echo "Publishing to npm..." | ||
npm publish --access public | ||
fi | ||
|
||
# Create GitHub release | ||
echo "Please create a release on GitHub now." | ||
echo "Visit: https://github.com/TACC/Core-Styles/releases/new" | ||
read -p "Press Enter once you've created the release..." | ||
|
||
# Fetch and check tags | ||
echo "Fetching tags..." | ||
git fetch --tags | ||
|
||
echo "Checking if tag is annotated..." | ||
if git describe --exact-match "$version_tag" >/dev/null 2>&1; then | ||
echo "Tag $version_tag is already annotated" | ||
else | ||
echo "Tag $version_tag is not annotated, annotating..." | ||
./bin/annotate-tag.sh "$version_tag" | ||
|
||
echo "Force pushing annotated tag..." | ||
git push --tags --force | ||
fi | ||
|
||
echo "Release process complete!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters