This repository was archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (83 loc) · 2.9 KB
/
continuous_release.yml
File metadata and controls
87 lines (83 loc) · 2.9 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: continuous_release
on:
# For unknown reasons, the push.tags event is not triggered when a tag is pushed so we'll use create and check the ref for now
create:
push:
branches: ["**"]
env:
GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}
jobs:
bump_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ env.GITHUB_TOKEN }}
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.7
with:
versionSpec: "5.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.7
- name: Format version
if: startsWith(github.ref, 'refs/heads/')
run: |
echo "BUILD_VERSION=${{ steps.gitversion.outputs.MajorMinorPatch }}-rc${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" >> $GITHUB_ENV
- name: Format version fo release
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "BUILD_VERSION=${{ steps.gitversion.outputs.MajorMinorPatch }}" >> $GITHUB_ENV
- name: Checkout on main
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/checkout@v3
with:
token: ${{ env.GITHUB_TOKEN }}
ref: "refs/heads/main"
- name: Bump Version
id: bump_version
run: |
make bump
echo "::set-output name=BuildVersion::$BUILD_VERSION"
env:
BUILD_VERSION: ${{ env.BUILD_VERSION }}
- name: Commit Version Bump on main
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: [skip ci] bump version to ${{ steps.bump_version.outputs.BuildVersion }}"
commit_options: "-a"
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: bump_version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ env.GITHUB_TOKEN }}
ref: "refs/heads/main"
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3.1.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}