-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (55 loc) · 1.57 KB
/
create-tag.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
name: create-tag
on:
push:
branches:
- main
paths:
- "version.go"
jobs:
unit-test:
runs-on: ubuntu-22.04
steps:
- name: Setup Go
continue-on-error: false
uses: actions/setup-go@v4
with:
go-version: "1.21" # The Go version to download (if necessary) and use.
- name: Checkout source code
uses: actions/checkout@v3
continue-on-error: false
- name: Cache Go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Run tests
continue-on-error: false
run: |
echo "$(go version)"
go test
cut-tag:
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
continue-on-error: false
- name: Get Version
continue-on-error: false
run: |
echo VERSION=`grep -E "MAJOR|MINOR|PATCH" version.go | cut -d '"' -f 2 | xargs echo -n | tr -s " " "."` >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ env.VERSION }}",
sha: context.sha
})