ci: add ci-build-pkg.sh

Signed-off-by: andy.lee <andy.lee@suse.com>
This commit is contained in:
andy.lee 2025-01-06 11:28:52 +08:00
parent d6bf6f1b55
commit 666fe7b3b8
No known key found for this signature in database
GPG Key ID: 10911689462678C7
2 changed files with 96 additions and 48 deletions

View File

@ -99,8 +99,8 @@ jobs:
- name: Upload build - name: Upload build
uses: 'google-github-actions/upload-cloud-storage@v2' uses: 'google-github-actions/upload-cloud-storage@v2'
# https://github.com/google-github-actions/upload-cloud-storage # https://github.com/google-github-actions/upload-cloud-storage
# TODO: replace test-release back to ${{ steps.build-hosted.outputs.BUILD_HOSTED_LOCATION }}
with: with:
# TODO: replace test-release back to ${{ steps.build-hosted.outputs.BUILD_HOSTED_LOCATION }}
path: ${{steps.build-hosted.outputs.BUILD_HOSTED_DIR}} path: ${{steps.build-hosted.outputs.BUILD_HOSTED_DIR}}
destination: releases.rancher.com/harvester-ui/dashboard/test-release destination: releases.rancher.com/harvester-ui/dashboard/test-release
parent: false parent: false
@ -143,65 +143,67 @@ jobs:
- name: Upload tar - name: Upload tar
uses: 'google-github-actions/upload-cloud-storage@v2' uses: 'google-github-actions/upload-cloud-storage@v2'
# TODO: replace test-release with ${{ env.REPO }}
with: with:
path: ${{steps.build-embedded.outputs.BUILD_EMBEDED_TGZ}} path: ${{steps.build-embedded.outputs.BUILD_EMBEDED_TGZ}}
# TODO: replace test-release with ${{ env.REPO }}
destination: releases.rancher.com/harvester-ui/test-release destination: releases.rancher.com/harvester-ui/test-release
parent: false parent: false
headers: |- headers: |-
cache-control: no-cache,must-revalidate cache-control: no-cache,must-revalidate
process_gcloudignore: false process_gcloudignore: false
# build-and-upload-harvester-plugin: build-and-upload-harvester-plugin:
# name: Build & Upload Plugin name: Build & Upload Plugin
# runs-on: ubuntu-latest runs-on: ubuntu-latest
# steps: steps:
# - uses: actions/checkout@v3 - uses: actions/checkout@v3
# with: with:
# fetch-depth: 1 fetch-depth: 1
# # Note - Cannot use the setup action here as it uses a different yarn install arg # Note - Cannot use the setup action here as it uses a different yarn install arg
# - uses: actions/setup-node@v4 - uses: actions/setup-node@v4
# with: with:
# node-version-file: '.nvmrc' node-version-file: '.nvmrc'
# cache: 'yarn' cache: 'yarn'
# - id: ci-build-pkg - id: ci-build-pkg
# name: Build pkg name: Build pkg
# run: ./shell/scripts/ci-build-pkg.sh harvester run: ./scripts/ci-build-pkg.sh harvester
# - id: upload-gate - id: upload-gate
# name: Upload Gate name: Upload Gate
# run: ./scripts/build-upload-gate run: ./scripts/build-upload-gate
# - name: Get gcs auth - name: Get gcs auth
# uses: rancher-eio/read-vault-secrets@main uses: rancher-eio/read-vault-secrets@main
# with: with:
# secrets: | secrets: |
# secret/data/github/repo/${{ github.repository }}/googleauthkey/harvester/credentials credential | GOOGLE_AUTH ; secret/data/github/repo/${{ github.repository }}/googleauthkey/harvester/credentials credential | GOOGLE_AUTH ;
# - name: Apply gcs auth - name: Apply gcs auth
# # https://github.com/google-github-actions/auth # https://github.com/google-github-actions/auth
# uses: 'google-github-actions/auth@v2' uses: 'google-github-actions/auth@v2'
# with: with:
# credentials_json: "${{ env.GOOGLE_AUTH }}" credentials_json: "${{ env.GOOGLE_AUTH }}"
# - name: Upload plugin tar - name: Upload plugin tar
# uses: 'google-github-actions/upload-cloud-storage@v2' uses: 'google-github-actions/upload-cloud-storage@v2'
# with: with:
# path: dist-pkg/${{steps.ci-build-pkg.outputs.PKG_TARBALL}} path: dist-pkg/${{steps.ci-build-pkg.outputs.PKG_TARBALL}}
# destination: releases.rancher.com/harvester-ui/plugin destination: releases.rancher.com/harvester-ui/plugin
# parent: false parent: false
# headers: |- headers: |-
# cache-control: no-cache,must-revalidate cache-control: no-cache,must-revalidate
# process_gcloudignore: false process_gcloudignore: false
# - name: Upload plugin directory - name: Upload plugin directory
# uses: 'google-github-actions/upload-cloud-storage@v2' uses: 'google-github-actions/upload-cloud-storage@v2'
# with: with:
# path: dist-pkg/${{steps.ci-build-pkg.outputs.PKG_NAME}} #TODO: replace test-release with ${{steps.ci-build-pkg.outputs.PKG_NAME}}
# destination: releases.rancher.com/harvester-ui/plugin/${{steps.ci-build-pkg.outputs.PKG_NAME}} path: dist-pkg/test-release
# parent: false #TODO: replace test-release with ${{steps.ci-build-pkg.outputs.PKG_NAME}}
# headers: |- destination: releases.rancher.com/harvester-ui/plugin/test-release
# cache-control: no-cache,must-revalidate parent: false
# process_gcloudignore: false headers: |-
cache-control: no-cache,must-revalidate
process_gcloudignore: false

46
scripts/ci-build-pkg.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env bash
yarn --pure-lockfile install
source scripts/version
if [[ $COMMIT_BRANCH == "master" ]]; then
VERSION="latest"
else
VERSION=$COMMIT_BRANCH
fi
echo "CI_BUILD_TAG: ${CI_BUILD_TAG}"
echo "GIT_TAG: ${GIT_TAG}"
echo "TAG_VERSION: ${TAG_VERSION}"
echo "CI Build Args"
echo "COMMIT: ${COMMIT}"
echo "COMMIT_BRANCH: ${COMMIT_BRANCH}"
echo "VERSION: ${VERSION}"
if [ -n "$GIT_TAG" ]; then
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$CI_BUILD_TAG ./shell/scripts/build-pkg.sh ${1} "true"
else
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$VERSION ./shell/scripts/build-pkg.sh ${1} "true"
fi
EXIT_CODE=$?
if [ -n "$GIT_TAG" ]; then
export PKG_NAME=${1}-${CI_BUILD_TAG}
export PKG_TARBALL=${PKG_NAME}.tar.gz
else
export PKG_NAME=${1}-${VERSION}
export PKG_TARBALL=${PKG_NAME}.tar.gz
fi
echo "CI Build Artefacts"
echo "Package Directory: ${PKG_NAME}"
echo "Package Tarball: ${PKG_TARBALL}"
ENV_OUTPUT="${GITHUB_OUTPUT:-"temp-env"}"
echo "PKG_TARBALL=${PKG_TARBALL}" >> "$ENV_OUTPUT"
echo "PKG_NAME=${PKG_NAME}" >> "$ENV_OUTPUT"
exit $EXIT_CODE