forked from coinset-org/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.3 KB
/
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
name: Release
on:
push:
branches:
- main
jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest tag
id: get_latest_tag
run: |
# Fetch all tags from the remote
git fetch --tags
# Get the latest tag from git
latest_tag=$(git describe --tags --abbrev=0 --match "v*")
echo "Latest tag: $latest_tag"
# If there are no tags, start from v0.0.0
if [ -z "$latest_tag" ]; then
echo "v0.0.0" > latest_tag.txt
else
echo "$latest_tag" > latest_tag.txt
fi
- name: Increment version
id: increment_version
run: |
latest_tag=$(cat latest_tag.txt)
# Remove the 'v' from the version to work with the numbers
version_without_v=${latest_tag#v}
# Split the tag into major, minor, and patch versions
IFS='.' read -r -a version_parts <<< "$version_without_v"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
# Increment the patch version
new_patch=$((patch + 1))
new_version="v$major.$minor.$new_patch"
echo "New version: $new_version"
# Save the new version to the GitHub environment to be used in future steps
echo "new_version=$new_version" >> $GITHUB_ENV
- name: Create and push new tag
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
run: |
new_version=${{ env.new_version }}
# Create a new tag
git tag "$new_version"
# Push the new tag to the remote repository
git push origin "$new_version"
release:
needs: tag
runs-on: ubuntu-latest
environment: goreleaser
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: ~> v1
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}