Skip to content

Commit 7105a2e

Browse files
committed
Separate PR ci from release ci
1 parent 86ddccd commit 7105a2e

File tree

2 files changed

+73
-38
lines changed

2 files changed

+73
-38
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Go
2-
on: [ push, pull_request ]
1+
name: Pull Request
2+
on: [ pull_request ]
33
jobs:
44

55
build:
@@ -17,10 +17,6 @@ jobs:
1717
- name: Check out code into the Go module directory
1818
uses: actions/checkout@v2
1919

20-
- name: Unshallow
21-
if: success() && startsWith(github.ref, 'refs/tags/v')
22-
run: git fetch --prune --unshallow
23-
2420
- name: Cache go module
2521
uses: actions/cache@v2
2622
with:
@@ -30,35 +26,4 @@ jobs:
3026
${{ runner.os }}-go-
3127
3228
- name: Build and Test
33-
run: go test -v -cover ./...
34-
35-
Docker-Image:
36-
runs-on: ubuntu-latest
37-
needs: build
38-
name: Docker Build, Tag, Push
39-
40-
steps:
41-
- name: Checkout
42-
uses: actions/checkout@v1
43-
44-
- name: Docker Login
45-
if: success() && startsWith(github.ref, 'refs/tags/v')
46-
env:
47-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
48-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
49-
run: |
50-
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
51-
52-
- name: GoReleaser
53-
uses: goreleaser/[email protected]
54-
if: success()
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
57-
with:
58-
version: latest
59-
args: release --rm-dist
60-
61-
- name: Clear
62-
if: always()
63-
run: |
64-
rm -f ${HOME}/.docker/config.json
29+
run: go test -v -race -cover ./...

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Go Build
2+
on:
3+
push:
4+
branches:
5+
- 'master'
6+
- 'releases/v*'
7+
tags:
8+
- 'v*'
9+
jobs:
10+
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
# Version here has to match one returned via https://golang.org/dl/?mode=json&include=all
20+
go-version: '1.14'
21+
id: go
22+
23+
- name: Check out code into the Go module directory
24+
uses: actions/checkout@v2
25+
26+
- name: Unshallow
27+
if: success() && startsWith(github.ref, 'refs/tags/v')
28+
run: git fetch --prune --unshallow
29+
30+
- name: Cache go module
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/go/pkg/mod
34+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
35+
restore-keys: |
36+
${{ runner.os }}-go-
37+
38+
- name: Build and Test
39+
run: go test -v -race -cover ./...
40+
41+
Docker-Image:
42+
runs-on: ubuntu-latest
43+
needs: build
44+
name: Docker Build, Tag, Push
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v1
49+
50+
- name: Docker Login
51+
if: success()
52+
env:
53+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
54+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
55+
run: |
56+
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
57+
58+
- name: GoReleaser
59+
uses: goreleaser/[email protected]
60+
if: success()
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
63+
with:
64+
version: latest
65+
args: release --rm-dist
66+
67+
- name: Clear
68+
if: always()
69+
run: |
70+
rm -f ${HOME}/.docker/config.json

0 commit comments

Comments
 (0)