-
Notifications
You must be signed in to change notification settings - Fork 226
141 lines (123 loc) · 6.3 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
name: Release
on:
push:
tags:
- v*.*.*
jobs:
release:
name: Release
runs-on: ubuntu-22.04
strategy:
matrix:
golang-version:
- "1.21"
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Setup golang
id: setup-go
uses: actions/setup-go@v3
with:
go-version: '^${{ matrix.golang-version }}'
- name: Setup fpm and make
run: |
sudo apt-get install -y --no-install-recommends ruby ruby-dev gcc g++ rpm musl-dev musl-tools
sudo apt-get install --no-install-recommends -y make
sudo gem install --no-document fpm
- name: Cache golang
id: cache-golang
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: clickhouse-backup-golang-${{ matrix.golang-version }}-${{ hashFiles('go.mod', '.github/workflows/*.yaml') }}
- name: Install golang dependencies
run: go mod download -x
if: |
steps.cache-golang.outputs.cache-hit != 'true'
- name: Extract DOCKER_TAG version
id: docker_tag
run: |
DOCKER_TAG=${GITHUB_REF##*/}
DOCKER_TAG=${DOCKER_TAG##*\\}
export DOCKER_TAG=${DOCKER_TAG#v}
echo "docker_tag=${DOCKER_TAG:-dev}" >> $GITHUB_OUTPUT
- name: Prepare binaries
id: make
env:
GOROOT: ${{ env.GOROOT_1_20_X64 }}
run: |
make build build-fips config test
#make build-fips-darwin
- name: Building deb, rpm and tar.gz packages
id: make_packages
run: |
set -x
export NAME=clickhouse-backup
export VERSION=$(git describe --always --tags --abbrev=0 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/c\1/;s/-/./g')
printf "amd64 arm64" | xargs -P 2 -d " " -I {} tar -czvf ${NAME}-linux-{}.tar.gz build/linux/{}/${NAME}
printf "amd64 arm64" | xargs -P 2 -d " " -I {} tar -czvf ${NAME}-darwin-{}.tar.gz build/darwin/{}/${NAME}
echo "tgz_linux_amd64=${NAME}-linux-amd64.tar.gz" >> $GITHUB_OUTPUT
echo "tgz_linux_arm64=${NAME}-linux-arm64.tar.gz" >> $GITHUB_OUTPUT
echo "tgz_darwin_amd64=${NAME}-darwin-amd64.tar.gz" >> $GITHUB_OUTPUT
echo "tgz_darwin_arm64=${NAME}-darwin-arm64.tar.gz" >> $GITHUB_OUTPUT
printf "amd64 arm64" | xargs -P 2 -d " " -I {} tar -czvf ${NAME}-linux-{}-fips.tar.gz build/linux/{}/${NAME}-fips
# printf "amd64 arm64" | xargs -P 2 -d " " -I {} tar -czvf ${NAME}-darwin-{}-fips.tar.gz build/darwin/{}/${NAME}-fips
echo "tgz_linux_amd64_fips=${NAME}-linux-amd64-fips.tar.gz" >> $GITHUB_OUTPUT
echo "tgz_linux_arm64_fips=${NAME}-linux-arm64-fips.tar.gz" >> $GITHUB_OUTPUT
# echo "tgz_darwin_amd64_fips=${NAME}-darwin-amd64-fips.tar.gz" >> $GITHUB_OUTPUT
# echo "tgz_darwin_arm64_fips=${NAME}-darwin-arm64-fips.tar.gz" >> $GITHUB_OUTPUT
make packages
cp -lv ./build/linux/*/*.deb ./
cp -lv ./build/linux/*/*.rpm ./
echo "rpm_amd64=${NAME}-${VERSION}-1.x86_64.rpm" >> $GITHUB_OUTPUT
echo "deb_amd64=${NAME}_${VERSION}_amd64.deb" >> $GITHUB_OUTPUT
echo "rpm_arm64=${NAME}-${VERSION}-1.aarch64.rpm" >> $GITHUB_OUTPUT
echo "deb_arm64=${NAME}_${VERSION}_arm64.deb" >> $GITHUB_OUTPUT
- name: Prepare release notes
id: release_notes
run: |
awk '/^# / {s++} s == 1 {print}' ChangeLog.md > /tmp/release_notes.md
echo "path=/tmp/release_notes.md" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
tag_name: v${{ steps.docker_tag.outputs.docker_tag }}
name: ${{ steps.docker_tag.outputs.docker_tag }}
body_path: ${{ steps.release_notes.outputs.path }}
draft: true
fail_on_unmatched_files: true
files: |
${{ steps.make_packages.outputs.rpm_amd64 }}
${{ steps.make_packages.outputs.rpm_arm64 }}
${{ steps.make_packages.outputs.deb_amd64 }}
${{ steps.make_packages.outputs.deb_arm64 }}
${{ steps.make_packages.outputs.tgz_linux_amd64 }}
${{ steps.make_packages.outputs.tgz_linux_arm64 }}
${{ steps.make_packages.outputs.tgz_darwin_amd64 }}
${{ steps.make_packages.outputs.tgz_darwin_arm64 }}
${{ steps.make_packages.outputs.tgz_linux_amd64_fips }}
${{ steps.make_packages.outputs.tgz_linux_arm64_fips }}
# ${{ steps.make_packages.outputs.tgz_darwin_amd64_fips }}
# ${{ steps.make_packages.outputs.tgz_darwin_arm64_fips }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Building docker image
env:
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
DOCKER_TAG: ${{ steps.docker_tag.outputs.docker_tag }}
run: |
export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io}
echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin ${DOCKER_REGISTRY}
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest --target=image_short --pull --push .
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest-fips --target=image_fips --pull --push .
docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:latest --target=image_full --pull --push .