forked from vmware-samples/vcenter-event-broker-appliance
-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (130 loc) · 5.08 KB
/
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
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
name: Release
on:
# release will only be created when ref is a tag starting with "v"
push:
tags:
- "v*"
# run all jobs with these defaults, unless specified otherwise
defaults:
run:
shell: bash
jobs:
release:
name: Create Release
timeout-minutes: 30
strategy:
matrix:
go-version: ["1.19"]
platform: ["ubuntu-latest"]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
fetch-depth: 0
ref: "master"
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: vmware-event-router/go.sum
- name: Setup ko
uses: ko-build/setup-ko@3aebd0597dc1e9d1a26bcfdb7cbeb19c131d3037
- name: Create CHANGELOG for Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE: quay.io/git-chglog/git-chglog
# https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2
IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3
run: |
# update CHANGELOG
docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o vmware-event-router/RELEASE_CHANGELOG.md $(basename "${{ github.ref }}" )
- name: GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200
with:
args: release --clean --release-notes RELEASE_CHANGELOG.md
workdir: vmware-event-router
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
pull-request:
needs: release
name: Create CHANGELOG PR
timeout-minutes: 10
runs-on: ubuntu-latest
continue-on-error: true # errors caused by this job won't stop workflow
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
# for changelog
fetch-depth: 0
ref: "master"
- name: Create CHANGELOG commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE: quay.io/git-chglog/git-chglog
# https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2
IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3
run: |
# update CHANGELOG
docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} -o CHANGELOG.md
git config user.email "${{ github.actor }}@users.noreply.github.com"
git config user.name "${{ github.actor }}"
git add CHANGELOG.md
git commit -m "Update CHANGELOG for $(basename ${{ github.ref }})"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
with:
delete-branch: true
title: "Update CHANGELOG"
body: |
Update CHANGELOG.md for new release
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
images:
needs: release
name: Create Github Package image and release.yaml
timeout-minutes: 30
strategy:
matrix:
go-version: ["1.19"]
platform: ["ubuntu-latest"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: vmware-event-router/go.sum
id: go
- name: Setup ko
uses: ko-build/setup-ko@3aebd0597dc1e9d1a26bcfdb7cbeb19c131d3037
- name: Get short COMMIT and TAG
run: |
echo "KO_COMMIT=$(echo -n $GITHUB_SHA | cut -c -8)" >> $GITHUB_ENV
echo "KO_TAG=$(basename "${{ github.ref }}")" >> $GITHUB_ENV
- name: Get Release URL
id: get_release_url
uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f # v1.2.3
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Build and push multi-arch image
working-directory: ./vmware-event-router
run: |
# build and push with pre-release tag
ko resolve --platform=linux/arm64,linux/amd64 --tags ${KO_COMMIT},${KO_TAG},latest -BRf deploy/event-router-k8s.yaml > release.yaml
- name: Upload Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_url.outputs.upload_url }}
asset_path: ./vmware-event-router/release.yaml
asset_name: release.yaml
asset_content_type: text/plain