-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (84 loc) · 3.23 KB
/
release.yaml
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
89
90
91
92
93
94
95
96
97
98
99
100
name: Release
on:
workflow_dispatch:
permissions:
contents: write
packages: write
# This is used for the identity challenge
# with sigstore/fulcio when outside PRs.
id-token: write
jobs:
release:
if : github.triggering_actor == 'zcubbs'
runs-on: ubuntu-latest
steps:
- name: Set Static Major and Minor Versions
id: static_version
run: |
echo "::set-output name=major::0"
echo "::set-output name=minor::1"
- name: Get latest release version
id: latest_version
run: |
latest_tag=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq .tag_name -r)
echo "::set-output name=version::$latest_tag"
continue-on-error: true
- name: Calculate new version
id: new_version
run: |
static_minor=${{ steps.static_version.outputs.minor }}
latest_minor=$(echo "${{ steps.latest_version.outputs.version }}" | cut -d. -f2)
patch=$(echo "${{ steps.latest_version.outputs.version }}" | cut -d. -f3 | tr -d 'v')
if [[ "$static_minor" != "$latest_minor" ]]; then
patch=0
else
let "patch+=1"
fi
new_version="v${{ steps.static_version.outputs.major }}.$static_minor.${patch}"
echo "::set-output name=version::$new_version"
- name: Checkout Code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
# remove tests in order to clean dependencies
- name: Remove xxx_test.go files
run: rm -rf *_test.go ./examples ./images
# cleanup test dependencies
- name: Cleanup dependencies
run: go mod tidy
- name: List files
run: tree -Cfi
- name: Write new go.mod into logs
run: cat go.mod
- name: Write new go.sum into logs
run: cat go.sum
- name: Create tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name '${{ github.triggering_actor }}'
git config --global user.email "${{ github.triggering_actor}}@users.noreply.github.com"
git add .
git commit --allow-empty -m 'bump ${{ steps.new_version.outputs.version }}'
git tag ${{ steps.new_version.outputs.version }}
git push origin ${{ steps.new_version.outputs.version }}
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
name: ${{ steps.new_version.outputs.version }}
tag_name: ${{ steps.new_version.outputs.version }}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v3.0.0
with:
distribution: goreleaser
version: latest
args: release -f .goreleaser.yaml --clean --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}