This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
165 lines (141 loc) · 3.93 KB
/
build-and-release.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build and Release
on:
workflow_dispatch:
branches:
- main
push:
branches:
- main
tags:
- 'v*'
pull_request:
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'
- name: Go caches
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ github.job }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ github.job }}-${{ runner.os }}-go-
- name: Run build
run: make build
publish-images:
name: Build and publish images
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
brokers: [memory-broker, redis-broker]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.19'
- name: Go caches
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ github.job }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ github.job }}-${{ runner.os }}-go-
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }}
- name: GCR metadata
id: gcr-meta
uses: docker/metadata-action@v4
with:
images: gcr.io/triggermesh/${{ matrix.brokers }}
tags: |
type=semver,pattern={{raw}}
type=sha,prefix=,suffix=,format=long
- name: Build and push image to gcr.io
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64,linux/ppc64le
file: cmd/${{ matrix.brokers }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.gcr-meta.outputs.tags }}
labels: ${{ steps.gcr-meta.outputs.labels }}
release:
name: Create Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: publish-images
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-tmcore:
name: Update TriggerMesh Core
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout triggermesh/triggermesh-core
uses: actions/checkout@v3
with:
path: 'tm-core'
ref: 'main'
repository: 'triggermesh/triggermesh-core'
token: ${{ secrets.BOT_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Update brokers dependency on tm-core
working-directory: tm-core
run: |
go get github.com/triggermesh/brokers
git --no-pager diff
- name: Commit and push changes
working-directory: tm-core
run: |
git add -A
git status --porcelain
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
git config --global user.name 'TriggerMesh Bot'
git config --global user.email '[email protected]'
git commit -m "Update brokers dependency to '${GITHUB_REF_NAME}'"
git push
fi