mirror of https://github.com/rancher/dashboard.git
Update publish shell workflow to allow for independent release of either shell or creators packages (#11697)
* add step for checking tag version matching + remove unused tmp_dir var + update creators version to match what was published on npm * add missing env var + script cleanup * updated publish-shell script to allow for independent publish of shell or creators pkgs via tag + minor changes to have it work on a PR just for testing * update string * update string * update string check with sed * revert wf and publish-shell to correct form * address pr comments * fix TAG export * stringify case strings + fix publish-shell script with path for creators pkg publish * re-trigger gates * add check if npm tag should be pre-release
This commit is contained in:
parent
a0dde4ed5a
commit
138601c6a6
|
|
@ -4,6 +4,7 @@ on:
|
|||
push:
|
||||
tags:
|
||||
- 'shell-pkg-v*'
|
||||
- 'creators-pkg-v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -21,6 +22,12 @@ jobs:
|
|||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Check Tags Version Matching
|
||||
env:
|
||||
TAG: ${{github.ref_name}}
|
||||
run: ./.github/workflows/scripts/check-package-tag-version.sh
|
||||
shell: bash
|
||||
|
||||
- name: Validate Plugin build system
|
||||
run: ./shell/scripts/test-plugins-build.sh
|
||||
shell: bash
|
||||
|
|
@ -47,4 +54,5 @@ jobs:
|
|||
- name: Publish Shell Package to npm
|
||||
run: ./shell/scripts/publish-shell.sh --npm
|
||||
env:
|
||||
TAG: ${{github.ref_name}}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
echo "Checking package tag version matching"
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
||||
BASE_DIR="$(
|
||||
cd $SCRIPT_DIR && cd ../.. &
|
||||
pwd
|
||||
)"
|
||||
SHELL_DIR=$BASE_DIR/shell
|
||||
CREATORS_DIR=$BASE_DIR/shell/creators/extension
|
||||
|
||||
echo "TAG ${TAG}"
|
||||
|
||||
# let's get the package name and version from the tag
|
||||
PKG_NAME=$(sed 's/-pkg-v.*//' <<< "$TAG")
|
||||
PKG_VERSION=$(sed 's/.*-pkg-v//'<<< "$TAG")
|
||||
|
||||
echo "PKG_NAME ${PKG_NAME}"
|
||||
echo "PKG_VERSION ${PKG_VERSION}"
|
||||
|
||||
# version comparison checks
|
||||
case $PKG_NAME in
|
||||
"shell")
|
||||
SHELL_VERSION=$(jq -r .version ${SHELL_DIR}/package.json)
|
||||
if [ "$SHELL_VERSION" == "$PKG_VERSION" ]; then
|
||||
echo "tag check: shell versions match"
|
||||
exit 0
|
||||
else
|
||||
echo "Version mismatch for the shell package publish => shell: ${SHELL_VERSION} vs tag: ${PKG_VERSION}. Please redo the tagging properly"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
"creators")
|
||||
CREATORS_VERSION=$(jq -r .version ${CREATORS_DIR}/package.json)
|
||||
if [ "$CREATORS_VERSION" == "$PKG_VERSION" ]; then
|
||||
echo "tag check: creators versions match"
|
||||
exit 0
|
||||
else
|
||||
echo "Version mismatch for the creators package publish => creators: ${CREATORS_VERSION} vs tag: ${PKG_VERSION}. Please redo the tagging properly"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "something went wrong with the tagging or versioning => TAG: ${TAG} , PKG_NAME: ${PKG_NAME}, PKG_VERSION: ${PKG_VERSION}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@rancher/create-extension",
|
||||
"description": "Rancher UI Extension generator",
|
||||
"version": "0.0.0",
|
||||
"version": "0.1.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "SUSE",
|
||||
"private": false,
|
||||
|
|
|
|||
|
|
@ -6,11 +6,17 @@ BASE_DIR="$(
|
|||
pwd
|
||||
)"
|
||||
SHELL_DIR=$BASE_DIR/shell/
|
||||
TMP_DIR=$BASE_DIR/tmp
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public $PUBLISH_ARGS"
|
||||
CREATORS_DIR=$BASE_DIR/shell/creators/extension
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public $NPM_TAG"
|
||||
FORCE_PUBLISH_TO_NPM="false"
|
||||
DEFAULT_YARN_REGISTRY="https://registry.npmjs.org"
|
||||
|
||||
# if TAG doesn't exist, we can exit as it's needed for any type of publish.
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "You need to set the TAG variable first!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${BASE_DIR}/node_modules" ]; then
|
||||
echo "You need to run 'yarn install' first"
|
||||
exit 1
|
||||
|
|
@ -26,33 +32,25 @@ if [ "$FORCE_PUBLISH_TO_NPM" == "true" ]; then
|
|||
export YARN_REGISTRY=$DEFAULT_YARN_REGISTRY
|
||||
fi
|
||||
|
||||
# We use the version from the shell package for the creator packages
|
||||
# Need to copy them to a temporary location, so we can patch the version number
|
||||
# before publishing
|
||||
|
||||
# To set a token for NPM registry auth: `npm config set //registry.npmjs.org/:_authToken <TOKEN>``
|
||||
|
||||
PKG_DIST=$BASE_DIR/dist-pkg/creators
|
||||
mkdir -p ${PKG_DIST}
|
||||
rm -rf ${PKG_DIST}/extension
|
||||
|
||||
pushd ${SHELL_DIR} >/dev/null
|
||||
|
||||
PKG_VERSION=$(node -p "require('./package.json').version")
|
||||
popd >/dev/null
|
||||
|
||||
echo "Publishing version: $PKG_VERSION"
|
||||
|
||||
cp -R ${SHELL_DIR}/creators/extension ${PKG_DIST}
|
||||
|
||||
sed -i.bak -e "s/\"0.0.0/"\"$PKG_VERSION"/g" ${PKG_DIST}/extension/package.json
|
||||
|
||||
rm ${PKG_DIST}/extension/package.json.bak
|
||||
|
||||
function publish() {
|
||||
NAME=$1
|
||||
FOLDER=$2
|
||||
|
||||
# if we pass a third arg, that is the version number
|
||||
# that we want to actually publish on NPM
|
||||
# they should match with the package.json version stated
|
||||
# because of the check in the "Check Tags Version Matching" step in the workflow
|
||||
if [ -n "$3" ]; then
|
||||
PKG_VERSION=$3
|
||||
fi
|
||||
|
||||
# if the PKG_VERSION has a - it means it will be a pre-release
|
||||
if [[ $PKG_VERSION == *"-"* ]]; then
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public --tag pre-release"
|
||||
fi
|
||||
|
||||
echo "Publishing ${NAME} from ${FOLDER}"
|
||||
pushd ${FOLDER} >/dev/null
|
||||
|
||||
|
|
@ -63,19 +61,6 @@ function publish() {
|
|||
cp -R ${BASE_DIR}/pkg/rancher-components/src/components ./rancher-components/
|
||||
fi
|
||||
|
||||
if [ "$NAME" == "Update" ]; then
|
||||
# Add files from the app and pkg creators to the update package
|
||||
mkdir -p ./extension
|
||||
cp -R ${BASE_DIR}/shell/creators/extension/* ./extension
|
||||
# Remove index.ts from pkg files, as we don't want to replace that
|
||||
rm -f ./extension/pkg/files/index.ts
|
||||
|
||||
# Update the package.json for the extension
|
||||
cd extension
|
||||
node ${SCRIPT_DIR}/record-deps.js
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Make a note of dependency versions, if required
|
||||
node ${SCRIPT_DIR}/record-deps.js
|
||||
|
||||
|
|
@ -93,10 +78,27 @@ function publish() {
|
|||
# Generate the type definitions for the shell
|
||||
${SCRIPT_DIR}/typegen.sh
|
||||
|
||||
# Publish the packages - don't tag the git repo and don't auto-increment the version number
|
||||
publish "Shell" ${SHELL_DIR}
|
||||
publish "Extension creator" ${PKG_DIST}/extension/
|
||||
|
||||
echo "Done"
|
||||
echo "TAG ${TAG}"
|
||||
|
||||
# let's get the package name and version from the tag
|
||||
PKG_NAME=$(sed 's/-pkg-v.*//' <<< "$TAG")
|
||||
PKG_V=$(sed 's/.*-pkg-v//'<<< "$TAG")
|
||||
|
||||
echo "PKG_NAME ${PKG_NAME}"
|
||||
echo "PKG_V ${PKG_V}"
|
||||
|
||||
# version comparison checks
|
||||
case $PKG_NAME in
|
||||
"shell")
|
||||
echo "Publishing only Shell pkg via tagged release"
|
||||
publish "Shell" ${SHELL_DIR} ${PKG_V}
|
||||
;;
|
||||
"creators")
|
||||
echo "Publishing only Creators pkg via tagged release"
|
||||
publish "Extension creator" ${CREATORS_DIR} ${PKG_V}
|
||||
;;
|
||||
*)
|
||||
echo "something went wrong with the tagging name => TAG: ${TAG} , PKG_NAME: ${PKG_NAME}. Admissable names are 'shell' and 'creator'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -88,9 +88,15 @@ rm ${SHELL_DIR}/package.json.bak
|
|||
# We might have bumped the version number but its not published yet, so this will fail
|
||||
sed -i.bak -e "s/\"version\": \"[0-9]*.[0-9]*.[0-9]*\(-alpha\.[0-9]*\|-release[0-9]*.[0-9]*.[0-9]*\|-rc\.[0-9]*\)\{0,1\}\",/\"version\": \"${SHELL_VERSION}\",/g" ${BASE_DIR}/pkg/rancher-components/package.json
|
||||
|
||||
# Publish shell
|
||||
echo "Publishing shell packages to local registry"
|
||||
# Publish shell pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
|
||||
echo "Publishing Shell package to local registry"
|
||||
yarn install
|
||||
export TAG="shell-pkg-v${SHELL_VERSION}"
|
||||
${SHELL_DIR}/scripts/publish-shell.sh
|
||||
|
||||
# Publish creators pkg (tag is needed as publish-shell is optimized to work with release-shell-pkg workflow)
|
||||
echo "Publishing Creators package to local registry"
|
||||
export TAG="creators-pkg-v${SHELL_VERSION}"
|
||||
${SHELL_DIR}/scripts/publish-shell.sh
|
||||
|
||||
# Publish rancher components
|
||||
|
|
|
|||
Loading…
Reference in New Issue