Skip to content

Commit c171255

Browse files
authored
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
1 parent 93a2294 commit c171255

37 files changed

+206
-154
lines changed

.github/workflows/build-extension-catalog.yml

+8-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ jobs:
2828

2929
steps:
3030
- name: Checkout repository
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
32+
33+
- name: Enable Corepack
34+
run: corepack enable
3235

3336
- name: Configure Git
3437
run: |
@@ -47,20 +50,14 @@ jobs:
4750
with:
4851
version: v3.8.0
4952

50-
- name: Setup Nodejs and npm
53+
- name: Setup Nodejs with yarn caching
5154
uses: actions/setup-node@v4
5255
with:
53-
node-version-file: '.nvmrc'
56+
cache: yarn
5457

5558
- name: Setup yarn
5659
run: npm install -g yarn
5760

58-
- name: Setup Nodejs with yarn caching
59-
uses: actions/setup-node@v4
60-
with:
61-
node-version-file: '.nvmrc'
62-
cache: yarn
63-
6461
- name: Install dependencies
6562
run: yarn
6663

@@ -75,9 +72,9 @@ jobs:
7572
- name: Build and push UI image
7673
run: |
7774
publish="yarn publish-pkgs -cp -r ${{ inputs.registry_target }} -o ${{ github.repository_owner }}"
78-
75+
7976
if [[ -n "${{ inputs.tagged_release }}" ]]; then
8077
publish="$publish -t ${{ inputs.tagged_release }}"
8178
fi
82-
79+
8380
$publish

.github/workflows/build-extension-charts.yml

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ jobs:
2828
contents: read
2929
steps:
3030
- name: Checkout
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
3232
with:
3333
fetch-depth: 0
3434

35+
- name: Enable Corepack
36+
run: corepack enable
37+
3538
- name: Configure Git
3639
run: |
3740
git config user.name 'github-actions[bot]'
@@ -42,20 +45,14 @@ jobs:
4245
with:
4346
version: v3.8.0
4447

45-
- name: Setup Nodejs and npm
48+
- name: Setup Nodejs with yarn caching
4649
uses: actions/setup-node@v4
4750
with:
48-
node-version-file: '.nvmrc'
51+
cache: yarn
4952

5053
- name: Setup yarn
5154
run: npm install -g yarn
5255

53-
- name: Setup Nodejs with yarn caching
54-
uses: actions/setup-node@v4
55-
with:
56-
node-version-file: '.nvmrc'
57-
cache: yarn
58-
5956
- name: Install dependencies
6057
run: yarn
6158

@@ -76,7 +73,7 @@ jobs:
7673
if [[ -n "${{ inputs.tagged_release }}" ]]; then
7774
publish="$publish -t ${{ inputs.tagged_release }}"
7875
fi
79-
76+
8077
$publish
8178
8279
- name: Upload charts artifact
@@ -98,9 +95,9 @@ jobs:
9895
pages: write
9996
steps:
10097
- name: Checkout
101-
uses: actions/checkout@v3
98+
uses: actions/checkout@v4
10299
with:
103-
ref: "${{ inputs.target_branch }}"
100+
ref: '${{ inputs.target_branch }}'
104101

105102
- name: Configure Git
106103
run: |
@@ -125,4 +122,3 @@ jobs:
125122
env:
126123
CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
127124
CR_SKIP_EXISTING: true
128-

.github/workflows/check-plugins.yaml

+25-19
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ jobs:
99
validate:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
- name: Setup Node.js
15-
uses: actions/setup-node@v4
16-
with:
17-
node-version-file: '.nvmrc'
18-
- name: Validate Plugin build system
19-
run: ./shell/scripts/test-plugins-build.sh
20-
shell: bash
12+
- name: Checkout
13+
uses: actions/checkout@v4
2114

22-
- name: Upload files
23-
uses: actions/upload-artifact@v3
24-
if: failure()
25-
with:
26-
name: test
27-
path: |
28-
/tmp/tmp.**/test-app
29-
!/tmp/tmp.**/test-app/node_modules/
30-
!/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/
31-
retention-days: 2
15+
- name: Enable Corepack
16+
run: corepack enable
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version-file: '.nvmrc'
22+
cache: 'yarn'
23+
24+
- name: Validate Plugin build system
25+
run: ./shell/scripts/test-plugins-build.sh
26+
shell: bash
27+
28+
- name: Upload files
29+
uses: actions/upload-artifact@v3
30+
if: failure()
31+
with:
32+
name: test
33+
path: |
34+
/tmp/tmp.**/test-app
35+
!/tmp/tmp.**/test-app/node_modules/
36+
!/tmp/tmp.**/test-app/pkg/test-pkg/node_modules/
37+
retention-days: 2

.github/workflows/release-shell-pkg.yaml

+45-45
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Publish Shell Package
33
on:
44
push:
55
tags:
6-
- 'shell-pkg-v*'
7-
- 'creators-pkg-v*'
6+
- 'shell-pkg-v*'
7+
- 'creators-pkg-v*'
88

99
jobs:
1010
build:
@@ -13,46 +13,46 @@ jobs:
1313
contents: read
1414
packages: write
1515
steps:
16-
- uses: actions/checkout@v3
17-
with:
18-
fetch-depth: 0
19-
persist-credentials: false
20-
21-
- uses: actions/setup-node@v4
22-
with:
23-
node-version-file: '.nvmrc'
24-
25-
- name: Check Tags Version Matching
26-
env:
27-
TAG: ${{github.ref_name}}
28-
run: ./.github/workflows/scripts/check-package-tag-version.sh
29-
shell: bash
30-
31-
- name: Validate Plugin build system
32-
run: ./shell/scripts/test-plugins-build.sh
33-
shell: bash
34-
35-
# Reset the local (ci) repository state because
36-
# The previous step (Validate Plugin build system) changes
37-
# the version number on package.json for Shell in order
38-
# to release it in verdaccio for it's tests
39-
- name: Reset repository (file system)
40-
run: |
41-
git reset --hard HEAD
42-
echo $YARN_REGISTRY
43-
cat ./shell/package.json
44-
45-
- uses: actions/setup-node@v4
46-
with:
47-
node-version-file: '.nvmrc'
48-
registry-url: 'https://registry.npmjs.org'
49-
scope: '@rancher'
50-
51-
- name: Install packages
52-
run: yarn install --frozen-lockfile
53-
54-
- name: Publish Shell Package to npm
55-
run: ./shell/scripts/publish-shell.sh --npm
56-
env:
57-
TAG: ${{github.ref_name}}
58-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: false
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
25+
- name: Check Tags Version Matching
26+
env:
27+
TAG: ${{github.ref_name}}
28+
run: ./.github/workflows/scripts/check-package-tag-version.sh
29+
shell: bash
30+
31+
- name: Validate Plugin build system
32+
run: ./shell/scripts/test-plugins-build.sh
33+
shell: bash
34+
35+
# Reset the local (ci) repository state because
36+
# The previous step (Validate Plugin build system) changes
37+
# the version number on package.json for Shell in order
38+
# to release it in verdaccio for it's tests
39+
- name: Reset repository (file system)
40+
run: |
41+
git reset --hard HEAD
42+
echo $NPM_REGISTRY
43+
cat ./shell/package.json
44+
45+
- uses: actions/setup-node@v4
46+
with:
47+
node-version-file: '.nvmrc'
48+
registry-url: 'https://registry.npmjs.org'
49+
scope: '@rancher'
50+
51+
- name: Install packages
52+
run: yarn install --frozen-lockfile
53+
54+
- name: Publish Shell Package to npm
55+
run: ./shell/scripts/publish-shell.sh --npm
56+
env:
57+
TAG: ${{github.ref_name}}
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

shell/creators/extension/app/app.package.json creators/extension/app/app.package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": false,
55
"engines": {
6-
"node": ">=20"
6+
"node": ">=16"
77
},
88
"dependencies": {
99
"cache-loader": "^4.1.0",
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodeLinker: node-modules
2+
pnpMode: false

shell/creators/extension/app/init creators/extension/app/init

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22
/* eslint-disable no-console */
33

4-
const { execSync } = require('child_process');
54
const path = require('path');
65
const fs = require('fs-extra');
76

@@ -14,9 +13,10 @@ const targets = {
1413
const files = [
1514
'tsconfig.json',
1615
'vue.config.js',
17-
'.gitignore',
16+
'gitignore',
1817
'.eslintignore',
1918
'.eslintrc.js',
19+
'.yarnrc.yml',
2020
'babel.config.js',
2121
'.vscode/settings.json'
2222
];
@@ -26,6 +26,7 @@ console.log('Creating Skeleton Application');
2626

2727
const args = process.argv;
2828
let appFolder = path.resolve('.');
29+
let shellVersion = '';
2930

3031
if ( args.length > 2 ) {
3132
const name = args[2];
@@ -40,7 +41,9 @@ let addGitlabWorkflow = false;
4041
let addWorkflowFolder = true;
4142

4243
// Check for Gitlab integration option
43-
if ( args.length > 3 ) {
44+
if ( args.length >= 3 ) {
45+
shellVersion = args[3];
46+
4447
for (let i = 3; i < args.length; i++) {
4548
switch (args[i]) {
4649
case '-l':
@@ -95,10 +98,7 @@ Object.keys(targets).forEach((target) => {
9598
const creatorPkgData = fs.readFileSync(path.join(__dirname, 'package.json'));
9699
const creatorPkg = JSON.parse(creatorPkgData);
97100

98-
// Fetch the latest version of @rancher/shell
99-
const shellVersion = execSync('npm view @rancher/shell version').toString().trim();
100-
101-
// Set the latest version of @rancher/shell in the dependencies
101+
// Set the package version of @rancher/shell in the dependencies
102102
pkg.dependencies['@rancher/shell'] = `^${ shellVersion }`;
103103

104104
// Rest of dependencies are in the _pkgs property of package.json - copy then across
@@ -138,8 +138,9 @@ if ( addWorkflowFolder ) {
138138

139139
// Copy base files
140140
files.forEach((file) => {
141+
const destinationFile = file === 'gitignore' ? '.gitignore' : file;
141142
const src = path.join(__dirname, 'files', file);
142-
const dest = path.join(appFolder, file);
143+
const dest = path.join(appFolder, destinationFile);
143144

144145
if (!fs.existsSync(dest)) {
145146
console.log(` Adding file: ${ file }`);

shell/creators/extension/app/package.json creators/extension/app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"init"
1212
],
1313
"engines": {
14-
"node": ">=20.0.0"
14+
"node": ">=16.0.0"
1515
},
1616
"_requires": [
1717
"core-js",

0 commit comments

Comments
 (0)