forked from ClarifiedSecurity/catapult
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (48 loc) · 1.8 KB
/
version.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
---
name: Adding a new version, tag & release
on:
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
version_tag_and_release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configuring collection & tag versions
run: |
# Setting variables
version_file="${{ vars.PROJECT_VERSION_FILE }}"
# Configuring git
git config --global user.name "${{ vars.PROJECT_CI_USERNAME }}"
git config --global user.email "${{ vars.PROJECT_CI_EMAIL }}"
# Updating the version
version_row_old=$(grep "version: " $version_file)
version=$(echo $version_row_old | cut -d: -f2)
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
patch=$(echo $version | cut -d. -f3)
patch_new=$(( $patch+1 ))
version_row_new="version: $major.$minor.$patch_new"
sed -i "s/$version_row_old/$version_row_new/" $version_file
TAG_NAME="v$major.$minor.$patch_new"
echo "LATEST_TAG=$TAG_NAME" >> $GITHUB_ENV
# Adding the changed file to git
git add $version_file
# Committing the change
git commit -m "Set ${{ vars.PROJECT_NAME }} version to $major.$minor.$patch_new"
git push
# Tagging and pushing the change
git tag $TAG_NAME
git push origin $TAG_NAME
# Creating temp changelog file
git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^^)..HEAD > CHANGELOG.md
- uses: ncipollo/release-action@v1
with:
tag: ${{ env.LATEST_TAG }}
bodyFile: CHANGELOG.md