-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (192 loc) · 6.39 KB
/
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
default: auto
options:
- auto
- patch
- minor
- major
prerelease:
description: "Increase to this prerelease version"
required: false
type: choice
default: none
options:
- none
- alpha
- beta
- rc
jobs:
create-release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
permissions:
contents: write # to create a github release
pull-requests: write # to create and update PRs
outputs:
branch: release/v${{ steps.cz-bump.outputs.version }}
version: ${{ steps.cz-bump.outputs.version }}
tag: v${{ steps.cz-bump.outputs.version }}
id: ${{ steps.draft-release.outputs.id }}
steps:
- uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4.5.0
with:
python-version: "3.10"
architecture: x64
- name: Bump version
id: cz-bump
uses: commitizen-tools/commitizen-action@0.16.3
with:
increment: ${{ github.event.inputs.bump != 'auto' && github.event.inputs.bump || '' }}
prerelease: ${{ github.event.inputs.prerelease != 'none' && github.event.inputs.prerelease || '' }}
commit: "false"
push: "false"
changelog: "true"
github_token: ${{ secrets.AUTOVERSIONING_BOT_TOKEN }}
# extra_requirements: 'git+https://github.com/meltano/commitizen-version-bump@main'
changelog_increment_filename: _changelog_fragment.md
no_raise: ""
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
id: create-pull-request
with:
# https://github.com/peter-evans/create-pull-request
commit-message: "chore: Bump package version"
title: "chore: Release v${{ steps.cz-bump.outputs.version }}"
body: |
Bump changelog for release v${{ steps.cz-bump.outputs.version }}
branch: release/v${{ steps.cz-bump.outputs.version }}
base: master
labels: release
- name: Approve Pull Request
if: ${{ steps.create-pull-request.outputs.pull-request-number != 0 }}
uses: juliangruber/approve-pull-request-action@v2.0.3
with:
# https://github.com/juliangruber/approve-pull-request-action
github-token: ${{ secrets.AUTOVERSIONING_BOT_TOKEN }}
number: ${{ steps.create-pull-request.outputs.pull-request-number }}
- name: Draft Release
id: draft-release
uses: softprops/action-gh-release@v1
with:
body_path: _changelog_fragment.md
tag_name: v${{ steps.cz-bump.outputs.version }}
prerelease: ${{ github.event.inputs.prerelease != 'none' }}
target_commitish: release/v${{ steps.cz-bump.outputs.version }}
files: build/*
draft: true
build-api:
runs-on: ubuntu-latest
permissions:
contents: write # to upload resources to github release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
needs:
- create-release
steps:
- uses: actions/checkout@v3.3.0
with:
ref: ${{ needs.create-release.outputs.branch }}
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: '~=1.20'
go-version-file: api/go.mod
cache-dependency-path: api/go.sum
cache: true
- name: Download packages
run: go mod download || true
- name: Build
run:
GOARCH=amd64 go build -o ../build/serve-linux-amd64 -ldflags "-s -w" ./serve.go &&
GOARCH=386 go build -o ../build/serve-linux-386 -ldflags "-s -w" ./serve.go &&
GOARCH=arm go build -o ../build/serve-linux-arm -ldflags "-s -w" ./serve.go
env:
CGO_ENABLED: "0"
GOOS: linux
working-directory: api
- name: Upload binaries to release
uses: xresloader/upload-to-github-release@v1.3.11
with:
file: build/*
release_id: ${{ needs.create-release.outputs.id }}
overwrite: true
build-api-image:
runs-on: ubuntu-latest
permissions:
contents: write # to upload resources to github release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
needs:
- create-release
steps:
- uses: actions/checkout@v3.3.0
with:
ref: ${{ needs.create-release.outputs.branch }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.10.0
install: true
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
id: deploy-image
with:
context: api
push: true
tags: mtrqq/autoversioned:${{ needs.create-release.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Write out docker image tag
run: echo '${{ steps.deploy-image.outputs.imageid }}' > docker_image_api.txt
- name: Upload binaries to release
uses: xresloader/upload-to-github-release@v1.3.11
with:
file: docker_image_api.txt
release_id: ${{ needs.create-release.outputs.id }}
overwrite: true
build-chart:
runs-on: ubuntu-latest
permissions:
contents: write # to upload resources to github release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
needs:
- create-release
steps:
- uses: actions/checkout@v3.3.0
with:
ref: ${{ needs.create-release.outputs.branch }}
- uses: azure/setup-helm@v3
with:
version: v3.11.1
- name: Create package
run: helm package charts/* -d ./packages
- uses: actions/checkout@v3.3.0
with:
ref: gh-pages
clean: false
- name: Update index.yaml
run: |
mv -v packages/* . && helm repo index --url https://mtrqq.github.io/autoversioned --merge index.yaml .
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_email: github-actions[bot]@users.noreply.github.com
commit_user_name: github-actions[bot]
commit_message: Release package for ${{ needs.create-release.outputs.tag }} release (${{ github.sha }})