-
Notifications
You must be signed in to change notification settings - Fork 482
88 lines (83 loc) · 3.78 KB
/
create-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# This workflow is used to create a github release from last tag pushed
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:
# The type of runner that the job will run on
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
gh repo clone $GITHUB_REPOSITORY
cd devtron
if [[ "$RELEASE_TYPE" == "stable" ]]
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
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
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:
GH_TOKEN: ${{ secrets.GIT_TOKEN }}
RELEASE_BRANCH: ${{ secrets.RELEASE_BRANCH }}
GIT_CONFIG_NAME: ${{ secrets.GIT_TARGET_USERNAME }}
GIT_CONFIG_EMAIL: ${{ secrets.GIT_TARGET_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" ]]
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
env:
RELEASE_BRANCH: ${{ secrets.RELEASE_BRANCH }}