-
Notifications
You must be signed in to change notification settings - Fork 15
136 lines (127 loc) · 4.31 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release-install-script:
type: boolean
description: "Release install script to AWS-CN S3 bucket"
required: false
default: true
env:
GO_VERSION: "1.21"
MAX_UPLOAD_RETRY_TIMES: 20
UPLOAD_RETRY_TIMEOUT: 10 # minutes
jobs:
build:
name: build-binary
if: ${{ github.event_name == 'push' }}
strategy:
matrix:
# The file format is gtctl-<os>-<arch>
include:
- os: ubuntu-latest
file: gtctl-linux-amd64
goos: linux
goarch: amd64
- os: ubuntu-latest
file: gtctl-linux-arm64
goos: linux
goarch: arm64
- os: macos-latest
file: gtctl-darwin-arm64
goos: darwin
goarch: arm64
- os: macos-latest
file: gtctl-darwin-amd64
goos: darwin
goarch: amd64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build project
run: make
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- name: Calculate checksum and rename binary
shell: bash
run: |
cd bin
chmod +x gtctl
tar -zcvf ${{ matrix.file }}.tgz gtctl
echo $(shasum -a 256 ${{ matrix.file }}.tgz | cut -f1 -d' ') > ${{ matrix.file }}.sha256sum
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.file }}
path: bin/${{ matrix.file }}.tgz
- name: Upload checksum of artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.file }}.sha256sum
path: bin/${{ matrix.file }}.sha256sum
- name: Upload artifacts to S3
uses: nick-invision/retry@v3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CN_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY}}
AWS_DEFAULT_REGION: ${{ vars.AWS_CN_RELEASE_BUCKET_REGION }}
with:
max_attempts: ${{ env.MAX_UPLOAD_RETRY_TIMES }}
timeout_minutes: ${{ env.UPLOAD_RETRY_TIMEOUT }}
command: |
aws s3 cp \
bin/${{ matrix.file }}.tgz \
s3://${{ vars.AWS_CN_RELEASE_BUCKET }}/releases/gtctl/${{ github.ref_name }}/${{ matrix.file }}.tgz && \
aws s3 cp \
bin/${{ matrix.file }}.sha256sum \
s3://${{ vars.AWS_CN_RELEASE_BUCKET }}/releases/gtctl/${{ github.ref_name }}/${{ matrix.file }}.sha256sum && \
aws s3 cp \
bin/${{ matrix.file }}.tgz \
s3://${{ vars.AWS_CN_RELEASE_BUCKET }}/releases/gtctl/latest/${{ matrix.file }}.tgz && \
aws s3 cp \
bin/${{ matrix.file }}.sha256sum \
s3://${{ vars.AWS_CN_RELEASE_BUCKET }}/releases/gtctl/latest/${{ matrix.file }}.sha256sum
release:
name: release-artifacts
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Publish release
uses: ncipollo/release-action@v1
with:
name: "Release ${{ github.ref_name }}"
prerelease: false
make_release: true
generateReleaseNotes: true
allowUpdates: true
tag: ${{ github.ref_name }}
artifacts: |
**/gtctl-*
release-install-script:
name: release-install-script
if: ${{ inputs.release-install-script }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Upload install.sh to S3
uses: nick-invision/retry@v4
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CN_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY}}
AWS_DEFAULT_REGION: ${{ vars.AWS_CN_RELEASE_BUCKET_REGION }}
with:
max_attempts: ${{ env.MAX_UPLOAD_RETRY_TIMES }}
timeout_minutes: ${{ env.UPLOAD_RETRY_TIMEOUT }}
command: |
aws s3 cp hack/install.sh s3://${{ vars.AWS_CN_RELEASE_BUCKET }}/releases/scripts/gtctl/install.sh