Skip to content

feat: Updated the release creation action to create tag as well #6439

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 54 additions & 20 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,122 @@
# This workflow is used to create a github release from last tag pushed
# This workflow is used to create tag and Release for OSS

name: Create Release

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or on push in charts directory of main branch.
on:

workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "create-release"

create-release-tag:
runs-on: ubuntu-latest

env:
GITHUB_TOKENS: ${{ secrets.GH_SYSTEMSDT_TOKEN }}
GIT_CONFIG_EMAIL: ${{ secrets.GH_SYSTEMSDT_EMAIL }}
GIT_CONFIG_NAME: ${{ secrets.GH_SYSTEMSDT_USERNAME }}
GIT_USERNAME: ${{ secrets.GH_SYSTEMSDT_USERNAME }}
GIT_REPO: ${{ github.repository }}
REPO: https://github.com/devtron-labs/devtron
RELEASE_BRANCH: "main"

steps:

- name: Configure Git
run: |
echo $GITHUB_TOKENS > tokens.txt
gh auth login --with-token < tokens.txt
git config --global user.email "$GIT_CONFIG_EMAIL"
git config --global user.name "$GIT_CONFIG_NAME"

- name: Clone repository and create tag
run: |
mkdir preci && cd preci
gh repo clone "$REPO"
cd $(basename "$REPO")
git checkout $RELEASE_BRANCH
git pull origin $RELEASE_BRANCH
NEXT_RELEASE_VERSION=v$(curl -s https://raw.githubusercontent.com/devtron-labs/charts/refs/heads/main/charts/devtron/Chart.yaml | grep 'appVersion' | awk '{print $2}')
# Create and push tag
git tag $NEXT_RELEASE_VERSION
git push -f https://$GIT_USERNAME:[email protected]/$GIT_REPO $NEXT_RELEASE_VERSION

create-release:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
# The type of runner that the job will run on
needs: create-release-tag
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Runs series of commands to create a release
- name: create-release
run: |
RELEASE_FILE_CONTENTS=$(curl -L -s "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${RELEASE_BRANCH}/manifests/release.txt" )
RELEASE_TYPE=$(echo $RELEASE_FILE_CONTENTS | awk '{print $1}')
FILE_NAME=${FILE_NAME:=releasenotes.md}
echo $RELEASE_TYPE
echo $GITHUB_REPOSITORY
echo $RELEASE_BRANCH
version=$(curl -s https://raw.githubusercontent.com/devtron-labs/devtron/refs/heads/main/charts/devtron/Chart.yaml | grep "appVersion" | awk -F ': ' '{print $2}' )
if [[ "$version" == *"-rc"* ]]; then
RELEASE_TYPE="beta"
else
RELEASE_TYPE="minor"
fi
gh repo clone $GITHUB_REPOSITORY
cd devtron
if [[ "$RELEASE_TYPE" == "stable" ]]
if [[ "$RELEASE_TYPE" == "major" || "$RELEASE_TYPE" == "minor" || "$RELEASE_TYPE" == "patch" ]]
then
tag=$(git tag --sort=committerdate | tail -1)
echo $tag
echo $RELEASE_BRANCH
echo $GITHUB_REPOSITORY
gh release create $tag --target $RELEASE_BRANCH -t $tag -R $GITHUB_REPOSITORY -F $FILE_NAME
git checkout -b release-bot
git config --global user.email "$GIT_CONFIG_EMAIL"
git config --global user.name "$GIT_CONFIG_NAME"
rm -f $FILE_NAME
touch $FILE_NAME
echo "## Bugs" > beta-releasenotes.md
echo "## Enhancements" >> beta-releasenotes.md
echo "## Documentation" >> beta-releasenotes.md
echo "## Others" >> beta-releasenotes.md
echo "beta -1 $tag" > manifests/release.txt
echo "## Bugs" > beta-releasenotes.md
git add .
git commit -am "Updated release-notes files"
git push -f https://${GIT_CONFIG_NAME}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY} release-bot
elif [[ "$RELEASE_TYPE" == "beta" ]]
then
git checkout -b release-bot
git config --global user.email "$GIT_CONFIG_EMAIL"
git config --global user.name "$GIT_CONFIG_NAME"
echo "## Bugs" > beta-releasenotes.md
echo "## Enhancements" >> beta-releasenotes.md
echo "## Documentation" >> beta-releasenotes.md
echo "## Others" >> beta-releasenotes.md
echo "## Bugs" > beta-releasenotes.md
git add .
git commit -am "Created release-notes files"
git push -f https://${GIT_CONFIG_NAME}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY} release-bot
echo "Not creating release due to beta"
fi
env:
RELEASE_BRANCH: "main"
GH_TOKEN: ${{ secrets.GH_SYSTEMSDT_TOKEN }}
RELEASE_BRANCH: ${{ secrets.RELEASE_BRANCH }}
GIT_CONFIG_NAME: ${{ vars.GH_SYSTEMSDT_USERNAME }}
GIT_CONFIG_EMAIL: ${{ secrets.GH_SYSTEMSDT_EMAIL }}
# Send notification on discord
- name: discord-notify
run: |
RELEASE_FILE_CONTENTS=$(curl -L -s "https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${RELEASE_BRANCH}/manifests/release.txt" )
RELEASE_TYPE=$(echo $RELEASE_FILE_CONTENTS | awk '{print $1}')
if [[ "$RELEASE_TYPE" == "stable" ]]
version=$(curl -s https://raw.githubusercontent.com/devtron-labs/devtron/refs/heads/main/charts/devtron/Chart.yaml | grep "appVersion" | awk -F ': ' '{print $2}' )
if [[ "$version" == *"-rc"* ]]; then
RELEASE_TYPE="beta"
else
RELEASE_TYPE="minor"
fi
if [[ "$RELEASE_TYPE" == "major" || "$RELEASE_TYPE" == "minor" || "$RELEASE_TYPE" == "patch" ]]
then
sudo apt install python3 python3-pip -y
pip install discord-webhook
export repo=$GITHUB_REPOSITORY
export webhook_url=${{ secrets.DISCORD_WEBHOOK_URL }}
curl -O https://raw.githubusercontent.com/pawan-59/scripts/main/python/release-note-discord.py
ls
python3 release-note-discord.py
elif [[ "$RELEASE_TYPE" == "beta" ]]
then
echo "Not sending notification due to beta"
fi

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
env:
RELEASE_BRANCH: ${{ secrets.RELEASE_BRANCH }}
Loading