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