From 4b373ac502685a9ac904e9aadc14215008064a55 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Mon, 23 Sep 2024 15:46:59 +0100 Subject: [PATCH 1/2] chore: setup bash script to side releases --- setup-release-branch.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 setup-release-branch.sh diff --git a/setup-release-branch.sh b/setup-release-branch.sh new file mode 100755 index 0000000..f19b94e --- /dev/null +++ b/setup-release-branch.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Generate a unique branch name using a timestamp +TIMESTAMP=$(date +"%Y%m%d_%H%M%S") +NEW_BRANCH="release-branch-$TIMESTAMP" + +# Create an empty tree +empty_tree=$(git hash-object -t tree /dev/null) + +# Create a new commit with just the contents of dist/npm +new_commit=$(git commit-tree -m "Add npm distribution files" $(git write-tree --prefix=dist/npm)) + +# Create the new branch pointing to this commit +git update-ref "refs/heads/$NEW_BRANCH" $new_commit + +# Push the new branch to the remote repository +git push origin $NEW_BRANCH + +echo "New branch '$NEW_BRANCH' has been created and pushed with the contents of /dist/npm" +echo "----------------------------" +echo "Install this branch using:" +echo "npm install '@neondatabase/serverless'@'github:neondatabase/serverless#$NEW_BRANCH'" From 31ddbe250a145963d8c0e5dea5da3fc8c8e39d09 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Tue, 24 Sep 2024 14:45:50 +0100 Subject: [PATCH 2/2] fix: validate script --- setup-release-branch.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup-release-branch.sh b/setup-release-branch.sh index f19b94e..6b96cf8 100755 --- a/setup-release-branch.sh +++ b/setup-release-branch.sh @@ -1,22 +1,25 @@ #!/bin/bash +set -eux # Generate a unique branch name using a timestamp TIMESTAMP=$(date +"%Y%m%d_%H%M%S") NEW_BRANCH="release-branch-$TIMESTAMP" # Create an empty tree -empty_tree=$(git hash-object -t tree /dev/null) +git hash-object -t tree /dev/null # Create a new commit with just the contents of dist/npm -new_commit=$(git commit-tree -m "Add npm distribution files" $(git write-tree --prefix=dist/npm)) +new_commit=$(git commit-tree -m "Add npm distribution files" "$(git write-tree --prefix=dist/npm)") # Create the new branch pointing to this commit -git update-ref "refs/heads/$NEW_BRANCH" $new_commit +git update-ref "refs/heads/$NEW_BRANCH" "$new_commit" # Push the new branch to the remote repository -git push origin $NEW_BRANCH +git push origin "$NEW_BRANCH" +set +x echo "New branch '$NEW_BRANCH' has been created and pushed with the contents of /dist/npm" echo "----------------------------" echo "Install this branch using:" echo "npm install '@neondatabase/serverless'@'github:neondatabase/serverless#$NEW_BRANCH'" +set -x