-
Notifications
You must be signed in to change notification settings - Fork 1
169 lines (154 loc) · 6.23 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release
run-name: Release ${{ github.event.release.tag_name }} by ${{ github.actor }}
on:
release:
types: [published]
env:
GO_VERSION: 1.22.0
jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: go test
run: go test ./...
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: run test
run: ./test_final_exec.sh
build-exec:
needs: [unit-test, integration-test]
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "${{ env.GO_VERSION }}"
ldflags: -X 'github.com/conduktor/ctl/utils.version=${{ github.event.release.tag_name }}' -X 'github.com/conduktor/ctl/utils.hash=${{ github.sha }}'
project_path: "./"
binary_name: "conduktor"
bump:
needs: [unit-test, integration-test]
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.CONDUKTORBOT_GHCR_RW }}
APP_VERSION: ${{ github.event.release.tag_name }}
APP_SHA: ${{ github.sha }}
steps:
- run: env
shell: bash
- uses: actions/checkout@v3
with:
repository: 'conduktor/homebrew-brew'
ref: main
path: homebrew-brew
token: ${{ secrets.CONDUKTORBOT_REPO_WRITE }}
- name: Update conduktor-ctl on homebrew
env:
GH_TOKEN: ${{ secrets.CONDUKTORBOT_REPO_WRITE }}
run: |
yq --version
gh version
gh auth status
export BRANCH=update_console-plus_$APP_VERSION
echo BRANCH $BRANCH
export BASE_BRANCH=main
echo BASE_BRANCH $BASE_BRANCH
VERIF_SHA=$(curl -s -L https://github.com/conduktor/ctl/archive/refs/tags/${APP_VERSION}.tar.gz | sha256sum | cut -f 1 -d " ")
echo VERIF_SHA $VERIF_SHA
export TITLE="Bump conduktor-ctl version to ${APP_VERSION}"
export BODY="Release https://github.com/conduktor/ctl/releases/tag/${APP_VERSION}"
export MESSAGE="${TITLE} .${BODY}"
echo TITLE $TITLE
echo BODY $BODY
echo MESSAGE $MESSAGE
cd homebrew-brew
git config user.name github-actions
git config user.email [email protected]
git checkout -b $BRANCH
sed -i 's/version "[^"]*"/version "'"$APP_VERSION"'"/' Formula/conduktor-cli.rb
sed -i 's/sha256 "[^"]*"/sha256 "'"$VERIF_SHA"'"/' Formula/conduktor-cli.rb
sed -i 's/gitSha\s*=\s*"[^"]*"/gitSha = "'"$APP_SHA"'"/' Formula/conduktor-cli.rb
git add Formula/conduktor-cli.rb
git commit -m "$MESSAGE"
git push origin $BRANCH
gh pr create --title "$TITLE" --body "$BODY" --repo 'https://github.com/conduktor/homebrew-brew' --base $BASE_BRANCH
gh pr merge --auto --squash --delete-branch
cd ..
build-docker:
name: Build and publish conduktor-ctl image
needs: [unit-test, integration-test]
runs-on: ubuntu-latest
env:
IMAGE_NAME: "conduktor-ctl"
LABEL_IMAGE_TITLE: "Conduktor ctl"
LABEL_IMAGE_DESCRIPTION: "Conduktor command line tools"
LABEL_IMAGE_AUTHORS: "Conduktor <[email protected]>"
LABEL_IMAGE_URL: "https://hub.docker.com/r/conduktor/conduktor-ctl"
LABEL_IMAGE_DOCUMENTATION: "https://docs.conduktor.io/conduktor"
LABEL_IMAGE_VENDOR: "Conduktor.io"
LABEL_IMAGE_LICENSE: "Apache-2.0"
PLATFORMS: "linux/amd64,linux/arm64"
steps:
- uses: actions/checkout@v3
- name: "Set latest"
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest_release_version=$(gh release view -R ${{ github.repository }} --json tagName -q .tagName)
is_latest=$(test "${{ github.event.release.tag_name }}" == "${latest_release_version}" && echo true || echo false)
echo "IS_LATEST=${is_latest}" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v3
with:
platforms: ${{ env.PLATFORMS }}
- uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.PLATFORMS }}
- uses: docker/login-action@v2
with:
username: ${{ secrets.CONDUKTORBOT_DOCKER_HUB_USERNAME }}
password: ${{ secrets.CONDUKTORBOT_DOCKER_HUB_PAT }}
- uses: docker/metadata-action@v4
id: docker_meta
with:
images: docker.io/conduktor/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ github.event.release.tag_name }}
type=raw,value=latest,enable=${{ env.IS_LATEST }}
labels: |
org.opencontainers.image.title=${{ env.LABEL_IMAGE_TITLE }}
org.opencontainers.image.description=${{ env.LABEL_IMAGE_DESCRIPTION }}
org.opencontainers.image.authors=${{ env.LABEL_IMAGE_AUTHORS }}
org.opencontainers.image.documentation=${{ env.LABEL_IMAGE_DOCUMENTATION }}
org.opencontainers.image.vendor=${{ env.LABEL_IMAGE_VENDOR }}
org.opencontainers.image.licenses=${{ env.LABEL_IMAGE_LICENSE }}
org.opencontainers.image.url=${{ env.LABEL_IMAGE_URL }}
org.opencontainers.image.version=${{ github.event.release.tag_name }}
- name: Build ${{ env.IMAGE_NAME }}
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event.release.prerelease == false }} # only push on final release
file: docker/Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
github-token: ${{ secrets.GITHUB_TOKEN }}
build-args: |
hash=${{ github.sha }}
version=${{ github.event.release.tag_name }}