forked from vmware-tanzu/community-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (153 loc) · 5.76 KB
/
release-bucket.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
name: Release - Upload Bits to Buckets
on:
push:
branches:
- "!not_activated_on_branches!*"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-test.[0-9]+"
- "!*-dev.[0-9]+"
jobs:
setup-runner:
name: Start self-hosted EC2 runner
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'vmware-tanzu/community-edition'
runs-on: ubuntu-latest
outputs:
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Start EC2 runner
id: start-ec2-runner
shell: bash
run: |
echo "GITHUB_RUN_ID: ${GITHUB_RUN_ID}"
echo "GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER}"
echo "GITHUB_RUN_ATTEMPT: ${GITHUB_RUN_ATTEMPT}"
INSTANCE_NAME="id-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}"
echo "INSTANCE_NAME: ${INSTANCE_NAME}"
echo ::set-output name=ec2-instance-id::${INSTANCE_NAME}
build-release:
name: Build Release
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'vmware-tanzu/community-edition'
needs: setup-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.setup-runner.outputs.ec2-instance-id }} # run the job on the newly created runner
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: "1.17"
id: go
- name: Config credentials
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_ACCESS_TOKEN }}
shell: bash
run: |
git config --global pull.rebase true
git config --global url."https://git:$GITHUB_TOKEN@github.com".insteadOf "https://github.com"
- name: Check out code
uses: actions/checkout@v1
- name: Get Date
id: get-date
shell: bash
run: |
echo "::set-output name=date::$(date -u "+%Y-%m")"
- name: Restore Go Cache
uses: actions/cache@v3
timeout-minutes: 10
continue-on-error: true
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get the Tag
id: get_version
shell: bash
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Get dependencies
shell: bash
run: |
make get-deps
- name: Build
shell: bash
run: |
make ensure-deps
make release-buckets
- name: Auth to GCP Buckets
id: auth-to-gcp-buckets
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_BUCKET_SA }}
- name: Upload TCE Artifacts to Staging Bucket
id: upload-artifacts-staging
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: ./artifacts
destination: tce-cli-plugins-staging
- name: Upload TCE Artifacts to Update Bucket
id: upload-tce-artifacts-update
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: ./artifacts
destination: tce-cli-plugins
- name: Upload TF Artifacts to Update Bucket
id: upload-tf-artifacts-update
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: /tmp/tce-scratch-space/tanzu-framework/artifacts
destination: tce-framework-cli-plugins/artifacts
parent: false
- name: Upload TF Admin Artifacts to Update Bucket
id: upload-tf-artifacts-admin-update
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: /tmp/tce-scratch-space/tanzu-framework/artifacts-admin
destination: tce-framework-cli-plugins-admin/artifacts-admin
parent: false
- name: Prune Buckets
env:
TCE_CI_BUILD: true
shell: bash
run: make prune-buckets
- name: Upload TCE Artifacts to Release Bucket
id: upload-tce-artifacts-release
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: ./artifacts
destination: tce-tanzu-cli-plugins
- name: Upload TF Artifacts to Release Bucket
id: upload-tf-artifacts-release
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: /tmp/tce-scratch-space/tanzu-framework/artifacts
destination: tce-tanzu-cli-framework/artifacts
parent: false
- name: Upload TF Artifacts-Admin to Release Bucket
id: upload-tf-artifacts-admin-release
uses: google-github-actions/upload-cloud-storage@v0.8.0
with:
path: /tmp/tce-scratch-space/tanzu-framework/artifacts-admin
destination: tce-tanzu-cli-framework-admin/artifacts-admin
parent: false
teardown-runner:
name: Stop self-hosted EC2 runner
# Only run this job if we're in the main repo, not a fork.
if: github.repository == 'vmware-tanzu/community-edition'
needs:
- setup-runner # required to get output from the setup-runner job
- build-release # required to wait when the main job is done
runs-on: ubuntu-latest
steps:
- name: Stop EC2 runner
id: stop-ec2-runner
shell: bash
run: |
echo "GITHUB_RUN_ID: ${GITHUB_RUN_ID}"
echo "GITHUB_RUN_NUMBER: ${GITHUB_RUN_NUMBER}"
echo "GITHUB_RUN_ATTEMPT: ${GITHUB_RUN_ATTEMPT}"
INSTANCE_NAME="id-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}-${GITHUB_RUN_ATTEMPT}"
echo "INSTANCE_NAME: ${INSTANCE_NAME}"