-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (43 loc) · 1.51 KB
/
publish-version.yml
File metadata and controls
53 lines (43 loc) · 1.51 KB
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
name: Publish version
on:
push:
branches:
- main
jobs:
create_tag:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# Step 2: Set up Git for tagging
- name: Set up Git for tagging
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# Step 3: Get the latest tag and increment the minor version
- name: Get latest tag and increment
id: get_tag
run: |
# Fetch all tags
git fetch --tags
# Get the latest tag version
latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0")
echo "Latest tag: $latest_tag"
# Extract the version numbers (major, minor, patch)
major=$(echo $latest_tag | cut -d. -f1 | cut -dv -f2)
minor=$(echo $latest_tag | cut -d. -f2)
patch=$(echo $latest_tag | cut -d. -f3)
# Increment the minor version and reset patch to 0
new_minor=$((minor + 1))
new_version="v${major}.${new_minor}.0"
# Write the new version to the GITHUB_OUTPUT file for later use
echo "tag=$new_version" >> $GITHUB_OUTPUT
# Step 4: Create and push the new tag
- name: Create new tag
run: |
new_tag="${{ steps.get_tag.outputs.tag }}"
git tag $new_tag
git push origin $new_tag