2021-04-08 09:32:31 +02:00
|
|
|
name: "Build Package Workflow"
|
|
|
|
env:
|
|
|
|
DOCKER_COMPOSE_VERSION: 1.23.0
|
|
|
|
|
|
|
|
on:
|
2022-11-24 08:46:58 +01:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- release-*
|
2022-06-30 19:59:56 +02:00
|
|
|
|
2021-04-08 09:32:31 +02:00
|
|
|
jobs:
|
|
|
|
BUILD_PACKAGE:
|
|
|
|
env:
|
|
|
|
BUILD_PACKAGE: true
|
|
|
|
runs-on:
|
2022-11-24 08:46:58 +01:00
|
|
|
- ubuntu-20.04
|
2021-04-08 09:32:31 +02:00
|
|
|
steps:
|
2022-10-24 10:35:32 +02:00
|
|
|
- uses: actions/checkout@v3
|
2023-12-08 09:29:04 +01:00
|
|
|
- uses: 'google-github-actions/auth@v2'
|
2022-11-24 08:46:58 +01:00
|
|
|
with:
|
|
|
|
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
2023-12-19 11:16:29 +01:00
|
|
|
- uses: google-github-actions/setup-gcloud@v2
|
2021-04-08 09:32:31 +02:00
|
|
|
with:
|
2023-05-16 10:04:00 +02:00
|
|
|
version: '430.0.0'
|
2021-04-08 09:32:31 +02:00
|
|
|
- run: gcloud info
|
2024-04-12 07:46:29 +02:00
|
|
|
- name: Set up Go 1.22
|
2023-12-08 10:07:59 +01:00
|
|
|
uses: actions/setup-go@v5
|
2021-04-08 09:32:31 +02:00
|
|
|
with:
|
2024-10-10 07:36:18 +02:00
|
|
|
go-version: 1.23.2
|
2021-04-08 09:32:31 +02:00
|
|
|
id: go
|
2022-11-24 08:46:58 +01:00
|
|
|
- name: Setup Docker
|
2023-04-23 13:26:17 +02:00
|
|
|
uses: docker-practice/actions-setup-docker@master
|
2021-04-08 09:32:31 +02:00
|
|
|
with:
|
2023-02-17 06:53:30 +01:00
|
|
|
docker_version: 20.10
|
2021-04-08 09:32:31 +02:00
|
|
|
docker_channel: stable
|
2022-10-24 10:35:32 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-04-08 09:32:31 +02:00
|
|
|
- uses: jitterbit/get-changed-files@v1
|
|
|
|
id: changed-files
|
|
|
|
with:
|
|
|
|
format: space-delimited
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2022-10-24 10:35:32 +02:00
|
|
|
- uses: actions/checkout@v3
|
2021-04-08 09:32:31 +02:00
|
|
|
with:
|
|
|
|
path: src/github.com/goharbor/harbor
|
2021-04-23 05:55:30 +02:00
|
|
|
- name: Build Base Image
|
2021-07-05 06:04:49 +02:00
|
|
|
if: |
|
|
|
|
contains(steps.changed-files.outputs.modified, 'Dockerfile.base') ||
|
|
|
|
contains(steps.changed-files.outputs.modified, 'VERSION') ||
|
2023-05-11 08:49:22 +02:00
|
|
|
contains(steps.changed-files.outputs.modified, '.buildbaselog') ||
|
|
|
|
github.ref == 'refs/heads/main'
|
2021-04-08 09:32:31 +02:00
|
|
|
run: |
|
|
|
|
set -x
|
2021-06-02 10:04:29 +02:00
|
|
|
echo "BUILD_BASE=true" >> $GITHUB_ENV
|
2021-04-08 09:32:31 +02:00
|
|
|
- name: Build Package
|
|
|
|
run: |
|
|
|
|
set -x
|
|
|
|
env
|
|
|
|
df -h
|
|
|
|
harbor_target_bucket=""
|
|
|
|
target_branch="$(echo ${GITHUB_REF#refs/heads/})"
|
|
|
|
harbor_offline_build_bundle=""
|
|
|
|
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)
|
|
|
|
Harbor_Package_Version=$target_release_version-'build.'$GITHUB_RUN_NUMBER
|
|
|
|
|
2021-12-07 07:59:48 +01:00
|
|
|
if [[ $target_branch == "main" ]]; then
|
2021-04-08 09:32:31 +02:00
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
2021-06-02 10:04:29 +02:00
|
|
|
build_base_params=" BUILD_BASE=false"
|
2021-04-08 09:32:31 +02:00
|
|
|
cd src/github.com/goharbor/harbor
|
2021-06-02 10:04:29 +02:00
|
|
|
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
|
2023-05-18 12:47:42 +02:00
|
|
|
sudo make package_offline GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} TRIVYFLAG=true HTTPPROXY= ${build_base_params}
|
|
|
|
sudo make package_online GOBUILDTAGS="include_oss include_gcs" BASEIMAGETAG=${Harbor_Build_Base_Tag} VERSIONTAG=${Harbor_Assets_Version} PKGVERSIONTAG=${Harbor_Package_Version} TRIVYFLAG=true HTTPPROXY= ${build_base_params}
|
2021-04-08 09:32:31 +02:00
|
|
|
harbor_offline_build_bundle=$(basename harbor-offline-installer-*.tgz)
|
|
|
|
harbor_online_build_bundle=$(basename harbor-online-installer-*.tgz)
|
|
|
|
echo "Package name is: $harbor_offline_build_bundle"
|
|
|
|
echo "Package name is: $harbor_online_build_bundle"
|
|
|
|
|
|
|
|
source tests/ci/build_util.sh
|
|
|
|
cp ${harbor_offline_build_bundle} harbor-offline-installer-latest.tgz
|
2021-12-21 07:48:44 +01:00
|
|
|
cp ${harbor_online_build_bundle} harbor-online-installer-latest.tgz
|
2021-04-08 09:32:31 +02:00
|
|
|
uploader ${harbor_offline_build_bundle} $harbor_target_bucket
|
|
|
|
uploader ${harbor_online_build_bundle} $harbor_target_bucket
|
|
|
|
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
|
2021-12-21 07:48:44 +01:00
|
|
|
uploader harbor-online-installer-latest.tgz $harbor_target_bucket
|
2021-04-08 09:32:31 +02:00
|
|
|
echo "BUILD_BUNDLE=$harbor_offline_build_bundle" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
publishImage $target_branch $Harbor_Assets_Version "${{ secrets.DOCKER_HUB_USERNAME }}" "${{ secrets.DOCKER_HUB_PASSWORD }}"
|