Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify release instructions #3252

Merged
merged 12 commits into from
Jul 18, 2024
13 changes: 0 additions & 13 deletions .github/ISSUE_TEMPLATE/backport.md

This file was deleted.

5 changes: 5 additions & 0 deletions .github/workflows/feature-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Feature Release

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the action on'
required: true
default: 'unstable'

jobs:
feature-release:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/patch-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Patch Release

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the action on'
required: true
default: 'master'

jobs:
patch-release:
Expand All @@ -12,7 +17,7 @@ jobs:
shell: bash
id: extract_branch
run: |
echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "Branch: " $BRANCH
- name: checkout patch branch
uses: actions/checkout@v3
Expand Down
92 changes: 41 additions & 51 deletions .github/workflows/scripts/merge_unstable_to_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,46 @@ set -e
# Check if VERSION variable is set
if [ -z "$VERSION" ]; then
echo "VERSION variable is not set."
return 1;
exit 1
else
echo "VERSION is set to: $VERSION"
fi

# Check if NEXT_VERSION variable is set
if [ -z "$NEXT_VERSION" ]; then
echo "NEXT_VERSION variable is not set."
return 1;
exit 1
else
echo "NEXT_VERSION is set to: $VERSION"
echo "NEXT_VERSION is set to: $NEXT_VERSION"
fi

# Check if NEXT_BACK_PORT_VERSION variable is set
if [ -z "$NEXT_BACK_PORT_VERSION" ]; then
echo "NEXT_BACK_PORT_VERSION variable is not set."
return 1;
exit 1
else
echo "NEXT_BACK_PORT_VERSION is set to: $NEXT_BACK_PORT_VERSION"
fi


# See current branch
echo "# Current Branch: $(git branch --show-current)"
echo "Current Branch: $(git branch --show-current)"

# See head of current branch
echo "# Current Head: "
echo "Current Head: "
git log -n 1

# See current origin
echo "# See remotes: "
echo "See remotes: "
git remote -v

# Set git configs
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"

# Check if the branch exists
if git rev-parse --verify "$branch_name" >/dev/null 2>&1; then
exit 1
else
echo "Branch '$branch_name' does not exist."
fi

git checkout -b $NEXT_BACK_PORT_VERSION
git push -f origin $NEXT_BACK_PORT_VERSION
# Create and push the new backport branch
git checkout master
git checkout -b "$NEXT_BACK_PORT_VERSION"
git push origin "$NEXT_BACK_PORT_VERSION"

# Step 2: Make sure local unstable is up-to-date
git checkout unstable
Expand All @@ -64,11 +58,11 @@ if [ "$current_branch" = "unstable" ]; then
echo "Current Git branch is unstable."
else
echo "Current Git branch is not unstable."
return 2;
exit 2
fi

echo "Updating documentation"
jq --arg ver "$VERSION" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
jq --arg ver "$VERSION" '.versions += [$ver]' ./documentation/versions.json > /tmp/temp.json
mv /tmp/temp.json ./documentation/versions.json

git add .
Expand All @@ -77,85 +71,81 @@ echo "Documentation committed"

# Step 3: Create a merge commit and push it
git merge -s ours master -m "Merge master to unstable"
echo "# Master merged to unstable"
echo "Master merged to unstable"
git push origin unstable
echo "# Unstable pushed to remote"

echo "Unstable pushed to remote"

# Step 4: Fast-forward master to the merge commit
git checkout master
git merge unstable
echo "# unstable merged in master"
echo "Unstable merged in master"

git push
echo "# Unstable pushed to remote"
echo "Master pushed to remote"

# Update package.json
jq --arg ver "$VERSION" '.version = $ver' package.json >> /tmp/temp.json
jq --arg ver "$VERSION" '.version = $ver' package.json > /tmp/temp.json
mv /tmp/temp.json package.json

# Update package-lock.json
jq --arg ver "$VERSION" '.version = $ver' package-lock.json >> /tmp/temp.json
jq --arg ver "$VERSION" '.version = $ver' package-lock.json > /tmp/temp.json
mv /tmp/temp.json package-lock.json


# Check if version is updated in package.json
version_check_package=$(jq -r '.version' package.json)
if [ -z "$version_check_package" ]; then
echo "# Failed to update version in package.json"
return 3
if [ "$version_check_package" != "$VERSION" ]; then
echo "Failed to update version in package.json"
exit 3
else
echo "# Version updated in package.json"
echo "Version updated in package.json"
fi

# Check if version is updated in package-lock.json
version_check_package_lock=$(jq -r '.version' package-lock.json)
if [ -z "$version_check_package_lock" ]; then
echo "# Failed to update version in package-lock.json"
return 4
if [ "$version_check_package_lock" != "$VERSION" ]; then
echo "Failed to update version in package-lock.json"
exit 4
else
echo "# Version updated in package-lock.json"
echo "Version updated in package-lock.json"
fi

# Commit and push the updated version files
git add package.json package-lock.json
git commit -m "Update version to $VERSION"
git push


# Update new to new version in unstable
# Update new version in unstable
git checkout unstable

# Update package.json
jq --arg ver "$NEXT_VERSION" '.version = $ver' package.json >> /tmp/temp.json
jq --arg ver "$NEXT_VERSION" '.version = $ver' package.json > /tmp/temp.json
mv /tmp/temp.json package.json

# Update package-lock.json
jq --arg ver "$NEXT_VERSION" '.version = $ver' package-lock.json >> /tmp/temp.json
jq --arg ver "$NEXT_VERSION" '.version = $ver' package-lock.json > /tmp/temp.json
mv /tmp/temp.json package-lock.json


# Check if version is updated in package.json
# Check if version is updated in package.json for unstable
version_check_package_unstable=$(jq -r '.version' package.json)
if [ -z "$version_check_package_unstable" ]; then
echo "# Failed to update version in package.json for unstable"
return 3
if [ "$version_check_package_unstable" != "$NEXT_VERSION" ]; then
echo "Failed to update version in package.json for unstable"
exit 3
else
echo "# Version updated in package.json for unstable"
echo "Version updated in package.json for unstable"
fi

# Check if version is updated in package-lock.json
# Check if version is updated in package-lock.json for unstable
version_check_package_lock_unstable=$(jq -r '.version' package-lock.json)
if [ -z "$version_check_package_lock_unstable" ]; then
echo "# Failed to update version in package-lock.json for unstable"
return 4
if [ "$version_check_package_lock_unstable" != "$NEXT_VERSION" ]; then
echo "Failed to update version in package-lock.json for unstable"
exit 4
else
echo "# Version updated in package-lock.json for unstable"
echo "Version updated in package-lock.json for unstable"
fi

# Commit and push the updated version files
git add package.json package-lock.json
git commit -m "Update version to $NEXT_VERSION"
git push

git checkout master
git checkout master
13 changes: 9 additions & 4 deletions .github/workflows/scripts/new-feature-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

# Get the current version from package.json
PREV_VERSION=$(jq -r '.version' package.json)
echo "Prev Feature Version $PREV_VERSION"

Expand All @@ -10,23 +11,27 @@ echo "New Master Version $VERSION"
# Split the version number into major, minor, and patch components
IFS='.' read -ra VERSION_ARRAY <<< "$VERSION"

# Extract the minor and patch components
MINOR_VERSION="${VERSION_ARRAY[1]}"
PATCH_VERSION="${VERSION_ARRAY[2]}"

# Decrement the minor version for backport branch
((MINOR_VERSION--))

# Increment patch for new backport branch
NEXT_BACK_PORT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.x"

# Increment the minor component for the new unstable version
((MINOR_VERSION++))
((MINOR_VERSION++))

# Increment the minor component and construct the new version
# Construct the new unstable version
NEXT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.0-unstable"

echo "Next Unstable Version: $NEXT_VERSION"
echo "Next Backport Version: $NEXT_BACK_PORT_VERSION"

echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
echo "NEXT_BACK_PORT_VERSION=$NEXT_BACK_PORT_VERSION" >> $GITHUB_ENV
# Export the versions to the GitHub Actions environment
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_ENV"
echo "NEXT_BACK_PORT_VERSION=$NEXT_BACK_PORT_VERSION" >> "$GITHUB_ENV"
21 changes: 13 additions & 8 deletions .github/workflows/scripts/new-patch-version.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
#!/bin/bash

# Get the current version from package.json
PREV_VERSION=$(jq -r '.version' package.json)
echo "Prev Patch Version $PREV_VERSION"

# Split the version number into major, minor, and patch components
IFS='.' read -a VERSION_ARRAY <<< "$PREV_VERSION"
echo "SPLITTING COMPLETED"

major=${VERSION_ARRAY[0]}
minor=${VERSION_ARRAY[1]}
patch=${VERSION_ARRAY[2]}
echo "CURRENT PATCH VERSION" $patch
major="${VERSION_ARRAY[0]}"
minor="${VERSION_ARRAY[1]}"
patch="${VERSION_ARRAY[2]}"
echo "CURRENT PATCH VERSION $patch"

# Increment the patch version
patch=$((patch + 1))
echo "UPDATED PATCH VERSION" $patch
echo "UPDATED PATCH VERSION $patch"

# Form the new version string
VERSION="$major.$minor.$patch"

# Split the version number into major, minor, and patch components
# Split the new version number into major, minor, and patch components to validate
IFS='.' read -a VERSION_ARRAY_2 <<< "$VERSION"
if [[ ${#VERSION_ARRAY_2[@]} -lt 3 ]]; then
echo "Error: Invalid new version format"
exit 1
fi

if [ $BRANCH != "refs/heads/master" ]; then
# Set the branch name if it's not the master branch
if [ "$BRANCH" != "refs/heads/master" ]; then
BRANCH="${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.x"
fi

echo "Version $VERSION"

echo "VERSION=$VERSION" >> $GITHUB_ENV
# Export the new version to the GitHub Actions environment
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
Loading
Loading