-
Notifications
You must be signed in to change notification settings - Fork 46
131 lines (121 loc) · 5.24 KB
/
build-package.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
name: "Build Package Workflow"
env:
DOCKER_COMPOSE_VERSION: 1.23.0
on:
push:
branches:
- master
- release-*
schedule:
- cron: 0 2 * * *
jobs:
BUILD_PACKAGE:
env:
BUILD_PACKAGE: true
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: google-github-actions/setup-gcloud@master
with:
version: '285.0.0'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- run: gcloud info
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15.12
id: go
- name: setup Docker
uses: docker-practice/[email protected]
with:
docker_version: 20.10
docker_channel: stable
- name: setup Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v3
with:
buildx-version: latest
qemu-version: latest
- uses: jitterbit/get-changed-files@v1
id: changed-files
with:
format: space-delimited
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
with:
path: src/github.com/goharbor/harbor-arm
- name: Build Harbor-ARM Images
run: |
set -x
env
# the target release version is the version of next release(RC or GA). It needs to be updated on creating new release branch.
target_release_version=$(cat ./VERSION)-arm
Harbor_Package_Version=$target_release_version-'build.'$GITHUB_RUN_NUMBER
if [[ $target_branch == "master" ]]; then
Harbor_Assets_Version=$Harbor_Package_Version
harbor_target_bucket=$harbor_builds_bucket
else
Harbor_Assets_Version=$target_release_version
harbor_target_bucket=$harbor_releases_bucket/$target_branch
fi
if [[ $target_branch == "release-"* ]]; then
Harbor_Build_Base_Tag=$target_release_version
else
Harbor_Build_Base_Tag=dev-arm
fi
cd src/github.com/goharbor/harbor-arm
if [ -z "$BUILD_BASE" ] || [ "$BUILD_BASE" != "true" ]; then
echo "Do not need to build base images!"
else
build_base_params=" BUILD_BASE=true PUSHBASEIMAGE=true REGISTRYUSER=\"${{ secrets.DOCKER_HUB_USERNAME }}\" REGISTRYPASSWORD=\"${{ secrets.DOCKER_HUB_PASSWORD }}\""
fi
sudo make build BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY= ${build_base_params}
echo -en "${{ secrets.HARBOR_SIGN_KEY }}" | gpg --import
publishImage $target_branch $Harbor_Assets_Version "${{ secrets.DOCKER_HUB_USERNAME }}" "${{ secrets.DOCKER_HUB_PASSWORD }}"
- name: Build Package
run: |
set -x
env
df -h
harbor_target_bucket=""
target_branch="$(echo ${GITHUB_REF#refs/heads/})"
harbor_online_build_bundle=""
harbor_logs_bucket="harbor-ci-logs"
harbor_builds_bucket="harbor-builds"
harbor_releases_bucket="harbor-releases"
harbor_ci_pipeline_store_bucket="harbor-ci-pipeline-store/latest"
# the target release version is the version of next release(RC or GA). It needs to be updated on creating new release branch.
target_release_version=$(cat ./VERSION)-arm
Harbor_Package_Version=$target_release_version-'build.'$GITHUB_RUN_NUMBER
if [[ $target_branch == "master" ]]; then
Harbor_Assets_Version=$Harbor_Package_Version
harbor_target_bucket=$harbor_builds_bucket
else
Harbor_Assets_Version=$target_release_version
harbor_target_bucket=$harbor_releases_bucket/$target_branch
fi
if [[ $target_branch == "release-"* ]]; then
Harbor_Build_Base_Tag=$target_release_version
else
Harbor_Build_Base_Tag=dev-arm
fi
cd src/github.com/goharbor/harbor-arm
sudo make package_online GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} BUILDBIN=true NOTARYFLAG=true CHARTFLAG=true TRIVYFLAG=true HTTPPROXY=
harbor_online_build_bundle=$(basename harbor-online-installer-arm-*.tgz)
echo "Package name is: $harbor_online_build_bundle"
echo -en "${{ secrets.HARBOR_SIGN_KEY }}" | gpg --import
gpg -v -ab -u ${{ secrets.HARBOR_SIGN_KEY_ID }} $harbor_online_build_bundle
publishImage $target_branch $Harbor_Assets_Version "${{ secrets.DOCKER_HUB_USERNAME }}" "${{ secrets.DOCKER_HUB_PASSWORD }}"
- name: Slack Notification
uses: sonots/slack-notice-action@v3
with:
status: ${{ job.status }}
title: Build Package - ${{ env.BUILD_BUNDLE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()