-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (92 loc) · 3.3 KB
/
main.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
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
name: main
on:
push:
pull_request:
release:
types: [created]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16.2
uses: actions/setup-go@v1
with:
go-version: 1.16.2
id: go
- name: Set up Protoc 3.15.6
uses: arduino/setup-protoc@v1
with:
version: '3.15.6'
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Lint, test and build
run: |
# Get golint
export PATH=$PATH:$(go env GOPATH)/bin
go install golang.org/x/lint/[email protected]
# Get go protobuf plugin
go install google.golang.org/protobuf/cmd/[email protected]
# Lint, beautify and generate code
make lint
make generate
# Exit if there's any difference in the code after beautification + generation
git diff --exit-code
# Build
if [ ${{ github.event_name }} == "release" ]; then
# github.ref is in the form refs/tags/VERSION, so apply regex to just get version
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
else
VERSION=$(git rev-parse --short ${{ github.sha }})
fi
make VERSION=${VERSION}
make all
- name: Release
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
if: github.event_name != 'pull_request' && github.repository == 'jamjarlabs/jamjar-relay-server'
run: |
echo "$DOCKER_PASS" | docker login --username=$DOCKER_USER --password-stdin
if [ ${{ github.event_name }} == "release" ]; then
# This needs to be determined again, due to env vars not being shared between steps
# https://github.com/actions/starter-workflows/issues/68
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
docker tag jamjarlabs/jamjar-relay-server:${VERSION} jamjarlabs/jamjar-relay-server:latest
docker push jamjarlabs/jamjar-relay-server:${VERSION}
docker push jamjarlabs/jamjar-relay-server:latest
# Package binary
make package_all
# Package protobuf
make package_proto
else
docker push jamjarlabs/jamjar-relay-server:$(git rev-parse --short ${{ github.sha }})
fi
- name: Publish linux_amd64 binary
if: github.event_name == 'release'
uses: Shopify/[email protected]
with:
name: linux_amd64.tar.gz
path: linux_amd64.tar.gz
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish mac_amd64 binary
if: github.event_name == 'release'
uses: Shopify/[email protected]
with:
name: mac_amd64.tar.gz
path: mac_amd64.tar.gz
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish windows_amd64 binary
if: github.event_name == 'release'
uses: Shopify/[email protected]
with:
name: windows_amd64.tar.gz
path: windows_amd64.tar.gz
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish protobuf specs
if: github.event_name == 'release'
uses: Shopify/[email protected]
with:
name: protobuf.zip
path: protobuf.zip
repo-token: ${{ secrets.GITHUB_TOKEN }}