-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (53 loc) · 1.7 KB
/
build.yml
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
name: build
on:
push:
branches:
- main
tags:
- v**
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Determine Version
run: |
# determine version from tag
export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
if [[ $VERSION != v* ]]
then
export VERSION=""
echo "Building version-less (main or feature branch)"
else
# make version more Docker-friendly by dropping the 'v'
export VERSION=${VERSION:1:${#VERSION}}
echo "Building as ${VERSION}"
fi
echo "##[set-output name=version;]$VERSION"
id: determine_version
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Lint
run: go vet ./...
- name: Build
run: go build ./...
- name: Test
run: go test -v -coverprofile=coverage.cov -coverpkg ./... -covermode=atomic ./...
- uses: codecov/[email protected]
with:
files: coverage.cov
flags: unittests
- name: Push Release Docker Image
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker build -t ghcr.io/oxisto/oauth2go:latest .
docker tag ghcr.io/oxisto/oauth2go:latest ghcr.io/oxisto/oauth2go:$VERSION
docker push ghcr.io/oxisto/oauth2go:$VERSION
docker push ghcr.io/oxisto/oauth2go:latest
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ steps.determine_version.outputs.version }}