-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (52 loc) · 1.87 KB
/
manage_pipelines.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
name: Tag Latest Release
on:
push:
branches:
- 'main'
jobs:
release_latest:
runs-on: self-hosted
permissions: write-all
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Latest Tag
id: latest_tag
run: |
git fetch --tags
git reset --hard origin/main
git pull
TAG=$(git tag | tail -n1)
if [[ $TAG == '' ]]; then
CURRENT_COMMIT=''
COMMIT_DIFFERENCE='1'
else
CURRENT_COMMIT=$(git rev-list -n 1 $TAG) || echo "Did not find commit for Tag: $TAG"
COMMIT_DIFFERENCE=$(git log ${CURRENT_COMMIT}..${LATEST_COMMIT} --pretty=oneline | wc -l)
fi
LATEST_COMMIT=$(git rev-parse --verify HEAD)
COMMIT_MESSAGE=$(git log --format=%B -n $COMMIT_DIFFERENCE $LATEST_COMMIT)
COMMIT_DATETIME=$(date "+%m/%d/%Y %H:%M:%S")
echo -e "COMMIT_DATETIME=$COMMIT_DATETIME\nTAG=$TAG\nLATEST_COMMIT=$LATEST_COMMIT\nCURRENT_COMMIT=$CURRENT_COMMIT\nCOMMIT_DIFFERENCE=$COMMIT_DIFFERENCE\nCOMMIT_MESSAGE=$COMMIT_MESSAGE" | tee -a $GITHUB_ENV
- name: Delete Latest Tag
if: ${{ env.TAG != '' }}
id: delete_tag
run: |
git push --delete origin ${{ env.TAG }} || echo "Unable to Delete - Tag Not Found"
git tag -d ${{ env.TAG }}
git push
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: latest
release_name: Release - ${{ env.COMMIT_DATETIME }}
body: |
Released: ${{ env.COMMIT_DATETIME }}
Commit: ${{ env.LATEST_COMMIT }}
Changes:
${{ env.COMMIT_MESSAGE }}
draft: false
prerelease: false