mirror of https://github.com/rancher/dashboard.git
Ensure @rancher/shell version using tags (#11758)
* Ensure @rancher/shell version using tags Enable corepack for extension builds Migrate creators outside of shell dir Update creators path - switch to npm publish * Add NPM_REGISTRY to publish args * Fix creators_dir path - Bump ext package * Add update package version function in test script * Fix gitignore file name * Add .yarnrc.yml for skeleton - revert node versions
This commit is contained in:
parent
93a2294b12
commit
c171255899
|
|
@ -28,7 +28,10 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Enable Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
|
|
@ -47,20 +50,14 @@ jobs:
|
|||
with:
|
||||
version: v3.8.0
|
||||
|
||||
- name: Setup Nodejs and npm
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Setup yarn
|
||||
run: npm install -g yarn
|
||||
|
||||
- name: Setup Nodejs with yarn caching
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: yarn
|
||||
|
||||
- name: Setup yarn
|
||||
run: npm install -g yarn
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
|
|
@ -75,9 +72,9 @@ jobs:
|
|||
- name: Build and push UI image
|
||||
run: |
|
||||
publish="yarn publish-pkgs -cp -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}"
|
||||
|
||||
|
||||
if [[ -n "${{ inputs.tagged_release }}" ]]; then
|
||||
publish="$publish -t ${{ inputs.tagged_release }}"
|
||||
fi
|
||||
|
||||
|
||||
$publish
|
||||
|
|
|
|||
|
|
@ -28,10 +28,13 @@ jobs:
|
|||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Enable Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config user.name 'github-actions[bot]'
|
||||
|
|
@ -42,20 +45,14 @@ jobs:
|
|||
with:
|
||||
version: v3.8.0
|
||||
|
||||
- name: Setup Nodejs and npm
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Setup yarn
|
||||
run: npm install -g yarn
|
||||
|
||||
- name: Setup Nodejs with yarn caching
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: yarn
|
||||
|
||||
- name: Setup yarn
|
||||
run: npm install -g yarn
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
|
|
@ -76,7 +73,7 @@ jobs:
|
|||
if [[ -n "${{ inputs.tagged_release }}" ]]; then
|
||||
publish="$publish -t ${{ inputs.tagged_release }}"
|
||||
fi
|
||||
|
||||
|
||||
$publish
|
||||
|
||||
- name: Upload charts artifact
|
||||
|
|
@ -98,9 +95,9 @@ jobs:
|
|||
pages: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: "${{ inputs.target_branch }}"
|
||||
ref: '${{ inputs.target_branch }}'
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
|
|
@ -125,4 +122,3 @@ jobs:
|
|||
env:
|
||||
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||
CR_SKIP_EXISTING: true
|
||||
|
||||
|
|
|
|||
|
|
@ -9,23 +9,29 @@ jobs:
|
|||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
- name: Validate Plugin build system
|
||||
run: ./shell/scripts/test-plugins-build.sh
|
||||
shell: bash
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Upload files
|
||||
uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: test
|
||||
path: |
|
||||
/tmp/tmp.**/test-app
|
||||
!/tmp/tmp.**/test-app/node_modules/
|
||||
!/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/
|
||||
retention-days: 2
|
||||
- name: Enable Corepack
|
||||
run: corepack enable
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: 'yarn'
|
||||
|
||||
- name: Validate Plugin build system
|
||||
run: ./shell/scripts/test-plugins-build.sh
|
||||
shell: bash
|
||||
|
||||
- name: Upload files
|
||||
uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: test
|
||||
path: |
|
||||
/tmp/tmp.**/test-app
|
||||
!/tmp/tmp.**/test-app/node_modules/
|
||||
!/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/
|
||||
retention-days: 2
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ name: Publish Shell Package
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'shell-pkg-v*'
|
||||
- 'creators-pkg-v*'
|
||||
- 'shell-pkg-v*'
|
||||
- 'creators-pkg-v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -13,46 +13,46 @@ jobs:
|
|||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
- uses: actions/setup-node@v4
|
||||
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: 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
|
||||
- name: Validate Plugin build system
|
||||
run: ./shell/scripts/test-plugins-build.sh
|
||||
shell: bash
|
||||
|
||||
# Reset the local (ci) repository state because
|
||||
# The previous step (Validate Plugin build system) changes
|
||||
# the version number on package.json for Shell in order
|
||||
# to release it in verdaccio for it's tests
|
||||
- name: Reset repository (file system)
|
||||
run: |
|
||||
git reset --hard HEAD
|
||||
echo $YARN_REGISTRY
|
||||
cat ./shell/package.json
|
||||
# Reset the local (ci) repository state because
|
||||
# The previous step (Validate Plugin build system) changes
|
||||
# the version number on package.json for Shell in order
|
||||
# to release it in verdaccio for it's tests
|
||||
- name: Reset repository (file system)
|
||||
run: |
|
||||
git reset --hard HEAD
|
||||
echo $NPM_REGISTRY
|
||||
cat ./shell/package.json
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
scope: '@rancher'
|
||||
|
||||
- name: Install packages
|
||||
run: yarn install --frozen-lockfile
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
scope: '@rancher'
|
||||
|
||||
- name: Publish Shell Package to npm
|
||||
run: ./shell/scripts/publish-shell.sh --npm
|
||||
env:
|
||||
TAG: ${{github.ref_name}}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- name: Install packages
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Publish Shell Package to npm
|
||||
run: ./shell/scripts/publish-shell.sh --npm
|
||||
env:
|
||||
TAG: ${{github.ref_name}}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"version": "0.1.0",
|
||||
"private": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
"node": ">=16"
|
||||
},
|
||||
"dependencies": {
|
||||
"cache-loader": "^4.1.0",
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
nodeLinker: node-modules
|
||||
pnpMode: false
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
/* eslint-disable no-console */
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
|
||||
|
|
@ -14,9 +13,10 @@ const targets = {
|
|||
const files = [
|
||||
'tsconfig.json',
|
||||
'vue.config.js',
|
||||
'.gitignore',
|
||||
'gitignore',
|
||||
'.eslintignore',
|
||||
'.eslintrc.js',
|
||||
'.yarnrc.yml',
|
||||
'babel.config.js',
|
||||
'.vscode/settings.json'
|
||||
];
|
||||
|
|
@ -26,6 +26,7 @@ console.log('Creating Skeleton Application');
|
|||
|
||||
const args = process.argv;
|
||||
let appFolder = path.resolve('.');
|
||||
let shellVersion = '';
|
||||
|
||||
if ( args.length > 2 ) {
|
||||
const name = args[2];
|
||||
|
|
@ -40,7 +41,9 @@ let addGitlabWorkflow = false;
|
|||
let addWorkflowFolder = true;
|
||||
|
||||
// Check for Gitlab integration option
|
||||
if ( args.length > 3 ) {
|
||||
if ( args.length >= 3 ) {
|
||||
shellVersion = args[3];
|
||||
|
||||
for (let i = 3; i < args.length; i++) {
|
||||
switch (args[i]) {
|
||||
case '-l':
|
||||
|
|
@ -95,10 +98,7 @@ Object.keys(targets).forEach((target) => {
|
|||
const creatorPkgData = fs.readFileSync(path.join(__dirname, 'package.json'));
|
||||
const creatorPkg = JSON.parse(creatorPkgData);
|
||||
|
||||
// Fetch the latest version of @rancher/shell
|
||||
const shellVersion = execSync('npm view @rancher/shell version').toString().trim();
|
||||
|
||||
// Set the latest version of @rancher/shell in the dependencies
|
||||
// Set the package version of @rancher/shell in the dependencies
|
||||
pkg.dependencies['@rancher/shell'] = `^${ shellVersion }`;
|
||||
|
||||
// Rest of dependencies are in the _pkgs property of package.json - copy then across
|
||||
|
|
@ -138,8 +138,9 @@ if ( addWorkflowFolder ) {
|
|||
|
||||
// Copy base files
|
||||
files.forEach((file) => {
|
||||
const destinationFile = file === 'gitignore' ? '.gitignore' : file;
|
||||
const src = path.join(__dirname, 'files', file);
|
||||
const dest = path.join(appFolder, file);
|
||||
const dest = path.join(appFolder, destinationFile);
|
||||
|
||||
if (!fs.existsSync(dest)) {
|
||||
console.log(` Adding file: ${ file }`);
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"init"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"_requires": [
|
||||
"core-js",
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const creatorPkg = require('./package.json');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
let extensionName = '';
|
||||
|
|
@ -11,6 +12,7 @@ let appName = '';
|
|||
let updateOnly = false;
|
||||
let skeletonOnly = false;
|
||||
let ignoreShellDepCheck = false;
|
||||
let tagUsed = ''; // To store the inferred tag
|
||||
|
||||
args.forEach((arg, index) => {
|
||||
switch (arg) {
|
||||
|
|
@ -47,6 +49,45 @@ if ( !extensionName && !updateOnly && !skeletonOnly ) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
// Infer the tag used based on the installed version and dist-tags
|
||||
try {
|
||||
const packageName = creatorPkg.name;
|
||||
const currentVersion = creatorPkg.version;
|
||||
|
||||
// Fetch the dist-tags from npm
|
||||
const distTags = JSON.parse(execSync(`npm view ${ packageName } dist-tags --json`).toString());
|
||||
|
||||
// Find the tag matching the current version
|
||||
tagUsed = Object.keys(distTags).find((tag) => distTags[tag] === currentVersion) || 'latest';
|
||||
|
||||
console.log(`Inferred tag used: ${ tagUsed }`);
|
||||
} catch (error) {
|
||||
console.error('Error inferring tag:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Now, check the version of `@rancher/shell` package based on the inferred tag
|
||||
let shellVersion = 'latest';
|
||||
const shellPackageName = '@rancher/shell';
|
||||
|
||||
try {
|
||||
// Fetch the version of the `@rancher/shell` package that corresponds to the inferred tag
|
||||
const tagVersion = execSync(`npm view ${ shellPackageName } dist-tags.${ tagUsed }`).toString().trim();
|
||||
|
||||
if (tagVersion) {
|
||||
shellVersion = tagVersion;
|
||||
} else {
|
||||
const latestVersion = execSync(`npm view ${ shellPackageName } version`).toString().trim();
|
||||
|
||||
shellVersion = latestVersion;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(` Failed to determine version for ${ shellPackageName }:`, error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(` Using version ${ shellVersion } for ${ shellPackageName }`);
|
||||
|
||||
const basePath = process.cwd();
|
||||
let skeletonPath;
|
||||
let isInsideSkeleton = false;
|
||||
|
|
@ -98,7 +139,7 @@ try {
|
|||
if ( !isInsideSkeleton && !skeletonExists ) {
|
||||
console.log(`Creating skeleton application: ${ appName }...`);
|
||||
// Pass all arguments to the app/init script
|
||||
execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ args.join(' ') }`, { stdio: 'inherit' });
|
||||
execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
|
||||
|
||||
// Ensure the skeleton path directory is created before attempting to change directory
|
||||
if ( !fs.existsSync(skeletonPath) ) {
|
||||
|
|
@ -124,7 +165,7 @@ try {
|
|||
// Check for package existence and create it if necessary
|
||||
if ( !pkgExists ) {
|
||||
console.log(`Creating package: ${ extensionName }...`);
|
||||
execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ args.join(' ') }`, { stdio: 'inherit' });
|
||||
execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
|
||||
}
|
||||
|
||||
if ( args.includes('--update') || args.includes('-u') ) {
|
||||
|
|
@ -1,17 +1,19 @@
|
|||
{
|
||||
"name": "@rancher/create-extension",
|
||||
"description": "Rancher UI Extension generator",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"license": "Apache-2.0",
|
||||
"author": "SUSE",
|
||||
"private": false,
|
||||
"bin": "./init",
|
||||
"packageManager": "yarn@4.4.1",
|
||||
"bin": {
|
||||
"create-extension": "./init"
|
||||
},
|
||||
"files": [
|
||||
"**/*",
|
||||
"init"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
"node": ">=16"
|
||||
},
|
||||
"_requires": [
|
||||
"core-js",
|
||||
|
|
@ -22,4 +24,4 @@
|
|||
"dependencies": {
|
||||
"fs-extra": "^10.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,10 +36,13 @@ const args = process.argv;
|
|||
const name = args[2];
|
||||
const folder = path.resolve('.');
|
||||
const pkgFolder = path.join(folder, 'pkg', name);
|
||||
let shellVersion = '';
|
||||
|
||||
let addTypeFolders = true;
|
||||
|
||||
if ( args.length > 3 ) {
|
||||
if ( args.length >= 3 ) {
|
||||
shellVersion = args[3];
|
||||
|
||||
for ( let i = 3; i < args.length; i++ ) {
|
||||
switch (args[i]) {
|
||||
case '--skip-templates':
|
||||
|
|
@ -115,20 +118,12 @@ function fetchLatestVersion() {
|
|||
|
||||
pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };
|
||||
|
||||
// Fetch the latest version of @rancher/shell
|
||||
const latestShellVersion = execSync('npm view @rancher/shell version').toString().trim() || null;
|
||||
|
||||
if (!latestShellVersion) {
|
||||
if ( !shellVersion ) {
|
||||
console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
|
||||
} else {
|
||||
const splitShellVersion = latestShellVersion.split('.');
|
||||
const majorVersion = splitShellVersion[0];
|
||||
const minorVersion = splitShellVersion[1];
|
||||
const parsedShellVersion = `${ majorVersion }.${ minorVersion }.0`;
|
||||
console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);
|
||||
|
||||
console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ parsedShellVersion }' to package.json`);
|
||||
|
||||
pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ parsedShellVersion }`;
|
||||
pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
|
||||
}
|
||||
|
||||
writePackageJson();
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"init"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"d3-color": "3.1.0",
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
"rancher": true,
|
||||
"scripts": {},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
"node": ">=16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "~5.0.0",
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
"upgrade"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.0.0"
|
||||
|
|
@ -67,14 +67,14 @@ You should be able to reach the older Ember UI by navigating to the Rancher API
|
|||
|
||||
There are a few options available to be passed as an argument to the `@rancher/extension` script:
|
||||
|
||||
| Option | Description |
|
||||
| :-----------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--update \| -u` | This will update all dependencies within the extension to match the declared versions in the shell. Update can be ran independently or along with creating an extension (e.g. `yarn create @rancher/extension my-extension --update` |
|
||||
| `--app-name \| -a <name>` | Allows specifying a different name for the skeleton application instead of using the extension name. |
|
||||
| `--skeleton-only \| -s` | Installs only the skeleton application without creating the extension package. |
|
||||
| `-l` | This will automatically add the [`.gitlab-ci.yml`](https://github.com/rancher/dashboard/blob/master/shell/creators/extension/app/files/.gitlab-ci.yml) pipeline file for integration with GitLab |
|
||||
| `-w` | Does not add the Github workflow files [`build-extension-catalog.yml`, `build-extension-charts.yml`](https://github.com/rancher/dashboard/tree/master/shell/creators/extension/app/files/.github/workflows) to be used as Github actions. These files will be added automatically by default. |
|
||||
| `-t` | Does not add the template folders automatically into the Extension package. These folders will be added automatically by default |
|
||||
| Option | Description |
|
||||
| :-----------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--update \| -u` | This will update all dependencies within the extension to match the declared versions in the shell. Update can be ran independently or along with creating an extension (e.g. `yarn create @rancher/extension my-extension --update` |
|
||||
| `--app-name \| -a <name>` | Allows specifying a different name for the skeleton application instead of using the extension name. |
|
||||
| `--skeleton-only \| -s` | Installs only the skeleton application without creating the extension package. |
|
||||
| `-l` | This will automatically add the [`.gitlab-ci.yml`](https://github.com/rancher/dashboard/blob/master/creators/extension/app/files/.gitlab-ci.yml) pipeline file for integration with GitLab |
|
||||
| `-w` | Does not add the Github workflow files [`build-extension-catalog.yml`, `build-extension-charts.yml`](https://github.com/rancher/dashboard/tree/master/creators/extension/app/files/.github/workflows) to be used as Github actions. These files will be added automatically by default. |
|
||||
| `-t` | Does not add the template folders automatically into the Extension package. These folders will be added automatically by default |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ You'll notice that if you reload the Rancher UI, the extension is not persistent
|
|||
|
||||
Creating a Release for your extension is the official avenue for loading extensions into any Rancher instance. As mentioned in the [Introduction](./introduction.md), the extension can be packaged into a Helm chart and added as a Helm repository to be easily accessible from your Rancher Manager.
|
||||
|
||||
We have created [workflows](https://github.com/rancher/dashboard/tree/master/shell/creators/extension/app/files/.github/workflows) for [Github Actions](https://docs.github.com/en/actions) which will automatically build, package, and release your extension as a Helm chart for use within your Github repository, and an [Extension Catalog Image](./advanced/air-gapped-environments) (ECI) which is published into a specified container registry (`ghcr.io` by default). Depending on the use case, you can utilize the Github repository as a [Helm repository](https://helm.sh/docs/topics/chart_repository/) endpoint which we can use to consume the chart in Rancher, or you can import the ECI into the Extension Catalog list and serve the Helm charts locally.
|
||||
We have created [workflows](https://github.com/rancher/dashboard/tree/master/creators/extension/app/files/.github/workflows) for [Github Actions](https://docs.github.com/en/actions) which will automatically build, package, and release your extension as a Helm chart for use within your Github repository, and an [Extension Catalog Image](./advanced/air-gapped-environments) (ECI) which is published into a specified container registry (`ghcr.io` by default). Depending on the use case, you can utilize the Github repository as a [Helm repository](https://helm.sh/docs/topics/chart_repository/) endpoint which we can use to consume the chart in Rancher, or you can import the ECI into the Extension Catalog list and serve the Helm charts locally.
|
||||
|
||||
> **Note:** GitLab support is offered through leverging the ECI build. For configuration instructions, follow the setps in the [Gitlab Integration](./publishing#gitlab-integration) section.
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ There are currently two options for building and publishing a extensions:
|
|||
1. Building the Helm charts and necessary assets of an extension that can be committed into a Github or Helm repository.
|
||||
2. Building an [Extension Catalog Image](./advanced/air-gapped-environments) that can be pushed or mirrored into a container registry.
|
||||
|
||||
As discussed in the [Getting Started](./extensions-getting-started#creating-a-release) section, we have established a [workflow](https://github.com/rancher/dashboard/tree/master/shell/creators/extension/app/files/.github/workflows) using [Github reusable workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows), that automatically handles the build and publication of both the Helm charts and ECI into the Extension's GitHub repository. However, this workflow can be omitted for a more hands-on approach to publishing Extensions.
|
||||
As discussed in the [Getting Started](./extensions-getting-started#creating-a-release) section, we have established a [workflow](https://github.com/rancher/dashboard/tree/master/creators/extension/app/files/.github/workflows) using [Github reusable workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows), that automatically handles the build and publication of both the Helm charts and ECI into the Extension's GitHub repository. However, this workflow can be omitted for a more hands-on approach to publishing Extensions.
|
||||
|
||||
> Note: An explanation on the workflow files can be found in the [Additional Release Configuration](#additional-release-configuration) section.
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ yarn publish-pkgs -c -p -r <REGISTRY> -o <ORGANIZATION>
|
|||
|
||||
# Additional Release Configuration
|
||||
|
||||
Depending on your use case, there are multiple options on building and creating releases. When building an extension within a Github repository, you have the option of utilizing an action that triggers [prebuilt workflows](https://github.com/rancher/dashboard/tree/master/shell/creators/extension/app/files/.github/workflows). When added to your extension, the `./github/workflows` directory will contain the files: `build-extension-charts.yml` and `build-extension-catalog.yml`. These workflows accomplish two seperate actions:
|
||||
Depending on your use case, there are multiple options on building and creating releases. When building an extension within a Github repository, you have the option of utilizing an action that triggers [prebuilt workflows](https://github.com/rancher/dashboard/tree/master/creators/extension/app/files/.github/workflows). When added to your extension, the `./github/workflows` directory will contain the files: `build-extension-charts.yml` and `build-extension-catalog.yml`. These workflows accomplish two seperate actions:
|
||||
|
||||
- `build-extension-charts` - Builds the Helm charts and necessary assets that are then published to the specified branch (defaults to `gh-pages`).
|
||||
- The versioning of these builds is determined by the Extension Package `version` property found in `./pkg/<package-name>/package.json`
|
||||
|
|
@ -147,7 +147,7 @@ By default, both of these actions are triggered by pushing into the `main` branc
|
|||
|
||||
## GitLab Integration
|
||||
|
||||
When building an extension that will be housed in a GitLab repository or hosted environment, there is only one option for publishing automatically - That is by utilizing the provided [GitLab Pipeline CI file](https://github.com/rancher/dashboard/blob/master/shell/creators/extension/app/files/.gitlab-ci.yml) that is generated when [creating the skeleton app](extensions-getting-started#creating-the-skeleton-app).
|
||||
When building an extension that will be housed in a GitLab repository or hosted environment, there is only one option for publishing automatically - That is by utilizing the provided [GitLab Pipeline CI file](https://github.com/rancher/dashboard/blob/master/creators/extension/app/files/.gitlab-ci.yml) that is generated when [creating the skeleton app](extensions-getting-started#creating-the-skeleton-app).
|
||||
|
||||
This pipeline will build an ECI and publish it to container registry (`registry.gitlab.com` by default) to allow for importing into Rancher Manager.
|
||||
The actual pipeline jobs are defined in the [Dashboard repo](https://github.com/rancher/dashboard/blob/master/.gitlab/workflows/build-extension-catalog.gitlab-ci.yml) to allow for proper versioning and to apply any updates to the pipeline without any additional work from the Extension developer.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
"node": ">=20.0.0"
|
||||
},
|
||||
"workspaces": [
|
||||
"pkg/rancher-components"
|
||||
"pkg/rancher-components",
|
||||
"creators/extension"
|
||||
],
|
||||
"scripts": {
|
||||
"build-pkg": "yarn lint && ./shell/scripts/build-pkg.sh",
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ BASE_DIR="$(
|
|||
pwd
|
||||
)"
|
||||
SHELL_DIR=$BASE_DIR/shell/
|
||||
CREATORS_DIR=$BASE_DIR/shell/creators/extension
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public $NPM_TAG"
|
||||
CREATORS_DIR=$BASE_DIR/creators/extension
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public --registry $NPM_REGISTRY $NPM_TAG"
|
||||
FORCE_PUBLISH_TO_NPM="false"
|
||||
DEFAULT_YARN_REGISTRY="https://registry.npmjs.org"
|
||||
DEFAULT_NPM_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
|
||||
|
|
@ -29,7 +29,7 @@ if [ "$1" == "--npm" ]; then
|
|||
fi
|
||||
|
||||
if [ "$FORCE_PUBLISH_TO_NPM" == "true" ]; then
|
||||
export YARN_REGISTRY=$DEFAULT_YARN_REGISTRY
|
||||
export NPM_REGISTRY=$DEFAULT_NPM_REGISTRY
|
||||
fi
|
||||
|
||||
pushd ${SHELL_DIR} >/dev/null
|
||||
|
|
@ -48,7 +48,7 @@ function publish() {
|
|||
|
||||
# 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"
|
||||
PUBLISH_ARGS="--no-git-tag-version --access public --registry $NPM_REGISTRY --tag pre-release"
|
||||
fi
|
||||
|
||||
echo "Publishing ${NAME} from ${FOLDER}"
|
||||
|
|
@ -64,7 +64,9 @@ function publish() {
|
|||
# Make a note of dependency versions, if required
|
||||
node ${SCRIPT_DIR}/record-deps.js
|
||||
|
||||
yarn publish . --new-version ${PKG_VERSION} ${PUBLISH_ARGS}
|
||||
echo "Publishing to registry: $NPM_REGISTRY"
|
||||
|
||||
npm publish ${PUBLISH_ARGS}
|
||||
RET=$?
|
||||
|
||||
popd >/dev/null
|
||||
|
|
@ -75,9 +77,6 @@ function publish() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Generate the type definitions for the shell
|
||||
${SCRIPT_DIR}/typegen.sh
|
||||
|
||||
echo "TAG ${TAG}"
|
||||
|
||||
# let's get the package name and version from the tag
|
||||
|
|
@ -87,6 +86,11 @@ PKG_V=$(sed 's/.*-pkg-v//'<<< "$TAG")
|
|||
echo "PKG_NAME ${PKG_NAME}"
|
||||
echo "PKG_V ${PKG_V}"
|
||||
|
||||
# Generate the type definitions for the shell
|
||||
if [ ${PKG_NAME} == "shell" ]; then
|
||||
${SCRIPT_DIR}/typegen.sh
|
||||
fi
|
||||
|
||||
# version comparison checks
|
||||
case $PKG_NAME in
|
||||
"shell")
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|||
BASE_DIR="$( cd $SCRIPT_DIR && cd ../.. & pwd)"
|
||||
SHELL_DIR=$BASE_DIR/shell/
|
||||
SHELL_VERSION="99.99.99"
|
||||
DEFAULT_YARN_REGISTRY="https://registry.yarnpkg.com/"
|
||||
VERDACCIO_YARN_REGISTRY="http://localhost:4873"
|
||||
DEFAULT_NPM_REGISTRY="https://registry.npmjs.org/"
|
||||
VERDACCIO_NPM_REGISTRY="http://localhost:4873"
|
||||
|
||||
echo ${SCRIPT_DIR}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ else
|
|||
rm -rf ~/.config/verdaccio/storage/@rancher/*
|
||||
fi
|
||||
|
||||
export YARN_REGISTRY=$VERDACCIO_YARN_REGISTRY
|
||||
export NPM_REGISTRY=$VERDACCIO_NPM_REGISTRY
|
||||
export NUXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Remove test package from previous run, if present
|
||||
|
|
@ -81,12 +81,17 @@ fi
|
|||
# We need to patch the version number of the shell, otherwise if we are running
|
||||
# with the currently published version, things will fail as those versions
|
||||
# are already published and Verdaccio will check, since it is a read-through cache
|
||||
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" ${SHELL_DIR}/package.json
|
||||
rm ${SHELL_DIR}/package.json.bak
|
||||
update_version_in_package_json() {
|
||||
local package_json_path="$1"
|
||||
local version="$2"
|
||||
|
||||
# Same as above for Rancher Components
|
||||
# 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
|
||||
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\": \"${version}\",/g" "$package_json_path"
|
||||
rm "${package_json_path}.bak"
|
||||
}
|
||||
|
||||
update_version_in_package_json "${SHELL_DIR}/package.json" "${SHELL_VERSION}"
|
||||
update_version_in_package_json "${BASE_DIR}/pkg/rancher-components/package.json" "${SHELL_VERSION}"
|
||||
update_version_in_package_json "${BASE_DIR}/creators/extension/package.json" "${SHELL_VERSION}"
|
||||
|
||||
# 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"
|
||||
|
|
@ -101,6 +106,9 @@ ${SHELL_DIR}/scripts/publish-shell.sh
|
|||
|
||||
# Publish rancher components
|
||||
yarn build:lib
|
||||
|
||||
npm set registry ${VERDACCIO_NPM_REGISTRY}
|
||||
yarn config set registry ${VERDACCIO_NPM_REGISTRY}
|
||||
yarn publish:lib
|
||||
|
||||
# We pipe into cat for cleaner logging - we need to set pipefail
|
||||
|
|
@ -167,7 +175,7 @@ function clone_repo_test_extension_build() {
|
|||
echo -e "\nSetting up $REPO_NAME repository locally\n"
|
||||
|
||||
# set registry to default (to install all of the other dependencies)
|
||||
yarn config set registry ${DEFAULT_YARN_REGISTRY}
|
||||
yarn config set registry ${DEFAULT_NPM_REGISTRY}
|
||||
|
||||
if [ "${TEST_PERSIST_BUILD}" != "true" ]; then
|
||||
echo "Removing folder ${BASE_DIR}/$REPO_NAME"
|
||||
|
|
@ -182,7 +190,7 @@ function clone_repo_test_extension_build() {
|
|||
yarn install
|
||||
|
||||
# set registry to local verdaccio (to install new shell)
|
||||
yarn config set registry ${VERDACCIO_YARN_REGISTRY}
|
||||
yarn config set registry ${VERDACCIO_NPM_REGISTRY}
|
||||
|
||||
# update package.json to use a specific version of shell
|
||||
sed -i.bak -e "s/\"\@rancher\/shell\": \"[0-9]*.[0-9]*.[0-9]*\",/\"\@rancher\/shell\": \"${SHELL_VERSION}\",/g" package.json
|
||||
|
|
@ -210,7 +218,7 @@ function clone_repo_test_extension_build() {
|
|||
# delete folder
|
||||
echo "Removing folder ${BASE_DIR}/$REPO_NAME"
|
||||
rm -rf ${BASE_DIR}/$REPO_NAME
|
||||
yarn config set registry ${DEFAULT_YARN_REGISTRY}
|
||||
yarn config set registry ${DEFAULT_NPM_REGISTRY}
|
||||
}
|
||||
|
||||
# Here we just add the extension that we want to include as a check (all our official extensions should be included here)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
"dist",
|
||||
"dist-pkg",
|
||||
"cypress",
|
||||
"shell/creators",
|
||||
"shell/scripts",
|
||||
"cypress",
|
||||
"./cypress.config.ts",
|
||||
|
|
|
|||
Loading…
Reference in New Issue