-
Notifications
You must be signed in to change notification settings - Fork 1.3k
108 lines (87 loc) · 2.52 KB
/
build-and-release.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
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
101
102
103
104
105
106
107
108
name: Test and release
on:
push:
branches:
- master
- ci_tests
tags:
- '*'
pull_request:
branches:
- master
env:
DOCKER_IMAGE_NAME: ghcr.io/cayleygraph/cayley
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Dependencies
run: go mod download
- name: Vet
run: ./vet.sh
- name: Build
run: go build -v ./cmd/cayley
- name: Test
run: go test -v ./...
release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/ci_tests')
needs:
- tests
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Dependencies
run: go mod download
- name: Download UI
run: go run cmd/download_ui/download_ui.go
- name: Release
uses: goreleaser/goreleaser-action@v6
if: startsWith(github.ref, 'refs/tags/v')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
name: Docker image
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/ci_tests')
needs:
- tests
steps:
- uses: actions/checkout@v4
- name: Docker build
run: |
docker build -t $DOCKER_IMAGE_NAME:dev --build-arg VERSION=${{ github.ref_name }} .
- name: Log in to the Container registry
uses: docker/login-action@v3
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/master')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push latest
if: (github.ref == 'refs/heads/master')
run: |
docker push $DOCKER_IMAGE_NAME:dev
- name: Push tagged
if: startsWith(github.ref, 'refs/tags/')
run: |
docker tag $DOCKER_IMAGE_NAME:dev $DOCKER_IMAGE_NAME:${{ github.ref_name }}
docker push $DOCKER_IMAGE_NAME:${{ github.ref_name }}
- name: Push latest
if: startsWith(github.ref, 'refs/tags/v')
run: |
docker tag $DOCKER_IMAGE_NAME:dev $DOCKER_IMAGE_NAME:latest
docker push $DOCKER_IMAGE_NAME:latest