-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amitz
committed
Mar 21, 2024
1 parent
ea33101
commit 1214c3d
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ue | ||
|
||
SEMVER_REGEX='^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' | ||
|
||
REL_VERSION=`echo $1 | sed -r 's/^[vV]?([0-9].+)$/\1/'` | ||
|
||
if [ `echo $REL_VERSION | pcre2grep "$SEMVER_REGEX"` ]; then | ||
echo "$REL_VERSION is a valid semantic version." | ||
else | ||
echo "$REL_VERSION is not a valid semantic version." | ||
exit 1 | ||
fi | ||
|
||
MAJOR_MINOR_VERSION=`echo $REL_VERSION | cut -d. -f1,2` | ||
RELEASE_BRANCH="release-$MAJOR_MINOR_VERSION" | ||
RELEASE_TAG="v$REL_VERSION" | ||
|
||
if [ `git rev-parse --verify origin/$RELEASE_BRANCH 2>/dev/null` ]; then | ||
echo "$RELEASE_BRANCH branch already exists, checking it out ..." | ||
git checkout $RELEASE_BRANCH | ||
else | ||
echo "$RELEASE_BRANCH does not exist, creating ..." | ||
git checkout -b $RELEASE_BRANCH | ||
git push origin $RELEASE_BRANCH | ||
fi | ||
echo "$RELEASE_BRANCH branch is ready." | ||
|
||
if [ `git rev-parse --verify $RELEASE_TAG 2>/dev/null` ]; then | ||
echo "$RELEASE_TAG tag already exists, aborting ..." | ||
exit 2 | ||
fi | ||
|
||
echo "Tagging $RELEASE_TAG ..." | ||
git tag $RELEASE_TAG | ||
echo "$RELEASE_TAG is tagged." | ||
|
||
echo "Pushing $RELEASE_TAG tag ..." | ||
git push origin $RELEASE_TAG | ||
echo "$RELEASE_TAG tag is pushed." |
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,32 @@ | ||
name: Create a release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
rel_version: | ||
description: 'Release version (examples: v1.3.0-rc.1, v1.3.0)' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
create-release: | ||
name: Creates release branch and tag | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install required packages | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install pcre2-utils | ||
- name: Create release branch and tag | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.LAVANET_BOT_TOKEN }} | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "LavaNet Bot" | ||
# Update origin with token | ||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | ||
./.github/scripts/create-release.sh ${{ inputs.rel_version }} |