Skip to content

Commit

Permalink
Add rc-push script (#6088)
Browse files Browse the repository at this point in the history
* add rc-push script

* source .env
  • Loading branch information
brunobar79 authored Sep 9, 2024
1 parent 29ad9ae commit e5cd981
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"clean:packager": "watchman watch-del-all",
"clean:node": "rm -rf node_modules",
"nuke": "./scripts/nuke.sh",
"rc-push": "./scripts/rc-push.sh",
"detox:android:release": "detox build -c android.emu.release && detox test -c android.emu.release",
"detox:android:tests": "detox test -c android.emu.debug --maxWorkers 2 -- --bail 1",
"detox:android": "detox build -c android.emu.debug && yarn detox:android:tests",
Expand Down
63 changes: 63 additions & 0 deletions scripts/rc-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
source .env

# Get the current branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

# Define the regular expression for the RC branch
BRANCH_REGEX="^rc-v([0-9]+)\.([0-9]+)\.([0-9]+)$"

# Exit early if the branch name doesn't match the pattern
if [[ ! $BRANCH_NAME =~ $BRANCH_REGEX ]]; then
echo "Error: you are not on the RC branch" >&2
exit 1
fi

# Extract version numbers from the branch name
MAJOR=${BASH_REMATCH[1]}
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}

# Create a tag from the version numbers (without the rc- prefix)
TAG="v$MAJOR.$MINOR.$PATCH"
echo "Creating tag $TAG"

# Create the git tag
git tag "$TAG"

# Push the tag to the remote repository
git push --tags

# Force push the current branch to master
echo "Force pushing branch $BRANCH_NAME to master"
git push origin "$BRANCH_NAME:master" --force

# Get the latest commit SHA on the master branch
COMMIT_SHA=$(git rev-parse master)

# Get the current UTC time in ISO 8601 format
DEPLOYED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

# App name, repository, and environment (fill in the correct values)
APP_NAME="rainbow"
REPO_NAME="rainbow-me/rainbow"
ENVIRONMENT="production"

echo "Notifying Swarmia about the new release"

# Make the HTTP request to Swarmia
curl -X POST \
https://hook.swarmia.com/deployments \
-H "Authorization: " \
-H "Content-Type: application/json" \
-d '{
"version": "'"$TAG"'",
"appName": "'"$APP_NAME"'",
"environment": "'"$ENVIRONMENT"'",
"deployedAt": "'"$DEPLOYED_AT"'",
"commitSha": "'"$COMMIT_SHA"'",
"repositoryFullName": "'"$REPO_NAME"'"
}'

echo "";
echo "Release created succesfully"

0 comments on commit e5cd981

Please sign in to comment.