From 66d452b5c51e43ad8c5388248fa3807e2ec6cf8f Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 3 Apr 2024 09:45:57 +0530 Subject: [PATCH 1/3] added github workflow for automated release --- .github/workflows/release | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/release diff --git a/.github/workflows/release b/.github/workflows/release new file mode 100644 index 0000000000..3eb3699c50 --- /dev/null +++ b/.github/workflows/release @@ -0,0 +1,55 @@ +name: Create Release on Branch Push + +on: + push: + branches: + - production + +permissions: + contents: write + +jobs: + release: + name: Release on Push + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Necessary to fetch all tags + + - name: Calculate next tag + id: calc_tag + run: | + YEAR=$(date +"%y") + WEEK=$(date +"%V") + LAST_TAG=$(git tag -l "v$YEAR.$WEEK.*" | sort -V | tail -n1) + LAST_TAG=$(echo "$LAST_TAG" | tr -d '\r' | sed 's/[[:space:]]*$//') + echo "Last Tag: $LAST_TAG" + if [[ $LAST_TAG == "" ]]; then + MINOR=0 + else + MINOR=$(echo $LAST_TAG | awk -F '.' '{print $NF}') + echo "Minor Version: $MINOR" + MINOR=$((MINOR + 1)) + fi + TAG="v$YEAR.$WEEK.$MINOR" + echo "TAG=$TAG" >> $GITHUB_ENV + echo "Next Tag: $TAG" + - name: Configure git + run: | + git config user.name github-actions + git config user.email github-actions@github.com + - name: Create and push tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git tag -a "$TAG" -m "Release $TAG" + git push origin "$TAG" + - name: Create release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "$TAG" \ + --repo="$GITHUB_REPOSITORY" \ + --title="$TAG" \ + --generate-notes From 2b84072a91cba1588174806567c0dc17b83c6017 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 3 Apr 2024 19:35:12 +0530 Subject: [PATCH 2/3] create a draft release --- .github/workflows/release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release b/.github/workflows/release index 3eb3699c50..1a418a889a 100644 --- a/.github/workflows/release +++ b/.github/workflows/release @@ -52,4 +52,5 @@ jobs: gh release create "$TAG" \ --repo="$GITHUB_REPOSITORY" \ --title="$TAG" \ - --generate-notes + --generate-notes \ + --draft From 80bd147a883f4dbf29cde3272045e7a6dcdece61 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 3 Apr 2024 19:38:23 +0530 Subject: [PATCH 3/3] fixed the release workflow file extension --- .github/workflows/{release => release.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{release => release.yml} (100%) diff --git a/.github/workflows/release b/.github/workflows/release.yml similarity index 100% rename from .github/workflows/release rename to .github/workflows/release.yml