-
Notifications
You must be signed in to change notification settings - Fork 562
74 lines (57 loc) · 2.3 KB
/
build_and_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
name: CDK CI
on:
workflow_dispatch:
release:
types: [released, prereleased]
jobs:
release:
name: Build and Release
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.22.2
- uses: actions/setup-node@v1
with:
node-version: 10.x
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
- name: Upload Release and Renew Changelog
env:
UPLOAD_URL: ${{ github.event.release.upload_url }}
API_HEADER: "Accept: application/vnd.github.v3+json"
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
RELEASE_URL: ${{ github.event.release.url }}
run: |
set -euo pipefail
set -x
go get github.com/mitchellh/gox
sudo apt-get install -y upx
export CGO_ENABLED=0
export GIT_COMMIT=$(git rev-list -1 HEAD)
export ldflags="-X github.com/cdk-team/CDK/pkg/cli.GitCommit=$GIT_COMMIT"
gox -parallel 5 -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm linux/arm64" -ldflags="-s -w $ldflags " -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}" ./cmd/cdk/
gox -parallel 5 -osarch="linux/386 linux/amd64 linux/arm64" -ldflags="-s -w $ldflags " -tags="thin" -output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}_thin" ./cmd/cdk/
# cdk_linux_386 cdk_linux_amd64 cdk_linux_arm cdk_linux_arm64
cp bin/cdk_linux_amd64 bin/cdk_linux_amd64_upx
upx bin/cdk_linux_amd64_upx
cp bin/cdk_linux_386 bin/cdk_linux_386_upx
upx bin/cdk_linux_386_upx
cp bin/cdk_linux_amd64_thin bin/cdk_linux_amd64_thin_upx
upx bin/cdk_linux_amd64_thin_upx
cp bin/cdk_linux_386_thin bin/cdk_linux_386_thin_upx
upx bin/cdk_linux_386_thin_upx
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g)
for FILE in bin/*
do
echo "Uploading ${FILE}";
curl \
-H "${API_HEADER}" \
-H "${AUTH_HEADER}" \
-H "Content-Type: $(file -b --mime-type ${FILE})" \
--data-binary "@${FILE}" \
"${UPLOAD_URL}?name=$(basename ${FILE})";
done
bash ".github/workflows/changelog.sh"