-
Notifications
You must be signed in to change notification settings - Fork 7
72 lines (63 loc) · 1.83 KB
/
release.yml
File metadata and controls
72 lines (63 loc) · 1.83 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Release
on:
push:
branches:
- main
workflow_dispatch:
# Add permissions block
permissions:
contents: write
packages: write
issues: write
pull-requests: write
jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest tag
id: get_latest_tag
run: |
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
- name: Create new tag
id: create_tag
run: |
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
# Extract version numbers
major=$(echo $latest_tag | cut -d. -f1 | tr -d 'v')
minor=$(echo $latest_tag | cut -d. -f2)
patch=$(echo $latest_tag | cut -d. -f3)
# Increment patch version
new_patch=$((patch + 1))
new_tag="v$major.$minor.$new_patch"
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag ${{ steps.create_tag.outputs.new_tag }}
git push origin ${{ steps.create_tag.outputs.new_tag }}
goreleaser:
needs: create-tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}