diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 794c4b3bf..b5d64102c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 - - name: Update v3 tag - run: git tag -f v3 + uses: actions/checkout@v4 + - name: Update v4 tag + run: git tag -f v4 - name: Push changes uses: ad-m/github-push-action@master with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59e8df39b..fe957a6c7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,16 +10,16 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - version: ["", "latest", "1.29.0"] + version: ["", "latest", "1.46.4"] fail-fast: false steps: # Checkout and install prerequisites - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup NodeJS - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: "16.x" + node-version: "20.x" # Run action according to the input version - name: Setup JFrog CLI diff --git a/README.md b/README.md index eb4f64932..29e7152d3 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Additionally, the Action incorporates the following features when utilizing JFro ## Usage ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 - run: jf --version ``` @@ -67,7 +67,7 @@ You can set the connection details to your JFrog Platform by using one of the fo You can use these environment variables in your workflow as follows: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 env: # JFrog platform url (for example: https://acme.jfrog.io) JF_URL: ${{ secrets.JF_URL }} @@ -97,7 +97,7 @@ The secret should be exposed as an environment variable with the _JF*ENV*_ prefi Here's how you do this: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 env: JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }} - run: | @@ -111,7 +111,7 @@ as the _JF_ENV_1_ environment variable. That's it - the ping command will now pi If you have multiple Config Tokens as secrets, you can use all of them in the workflow as follows: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 env: JF_ENV_1: ${{ secrets.JF_SECRET_ENV_1 }} JF_ENV_2: ${{ secrets.JF_SECRET_ENV_2 }} @@ -188,7 +188,7 @@ To utilize the OIDC protocol, follow these steps: Example step utilizing OpenID Connect: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 env: JF_URL: ${{ secrets.JF_URL }} with: @@ -218,7 +218,7 @@ are registered as the build artifacts. By default, the JFrog CLI version set in [action.yml](https://github.com/jfrog/setup-jfrog-cli/blob/master/action.yml) is used. To set a specific version, add the _version_ input as follows: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 with: version: X.Y.Z ``` @@ -226,12 +226,12 @@ By default, the JFrog CLI version set in [action.yml](https://github.com/jfrog/s It is also possible to set the latest JFrog CLI version by adding the _version_ input as follows: ```yml -- uses: jfrog/setup-jfrog-cli@v3 +- uses: jfrog/setup-jfrog-cli@v4 with: version: latest ``` -| Important: Only JFrog CLI versions 1.29.0 or above are supported. | +| Important: Only JFrog CLI versions 1.46.4 or above are supported. | | ----------------------------------------------------------------- | ## Downloading JFrog CLI from Artifactory @@ -244,7 +244,7 @@ Here's how you do this: 2. Set _download-repository_ input to jfrog-cli-remote: ```yml - - uses: jfrog/setup-jfrog-cli@v3 + - uses: jfrog/setup-jfrog-cli@v4 env: # JFrog platform url (for example: https://acme.jfrog.io) JF_URL: ${{ secrets.JF_URL }} diff --git a/lib/utils.js b/lib/utils.js index d0543502f..c9b7c323a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -220,20 +220,10 @@ class Utils { // Get Config Tokens created on your local machine using JFrog CLI. // The Tokens configured with JF_ENV_ environment variables. static getConfigTokens() { - let configTokens = new Set(Object.keys(process.env) + return new Set(Object.keys(process.env) .filter((envKey) => envKey.match(Utils.CONFIG_TOKEN_PREFIX)) .filter((envKey) => process.env[envKey]) .map((envKey) => { var _a; return ((_a = process.env[envKey]) === null || _a === void 0 ? void 0 : _a.trim()) || ''; })); - let legacyConfigTokens = new Set(Object.keys(process.env) - .filter((envKey) => envKey.match(Utils.CONFIG_TOKEN_LEGACY_PREFIX)) - .filter((envKey) => process.env[envKey]) - .map((envKey) => { var _a; return ((_a = process.env[envKey]) === null || _a === void 0 ? void 0 : _a.trim()) || ''; })); - if (legacyConfigTokens.size > 0) { - core.warning('The "JF_ARTIFACTORY_" prefix for environment variables is deprecated and is expected to be removed in v3. ' + - 'Please use the "JF_ENV_" prefix instead. The environment variables value should not be changed.'); - } - legacyConfigTokens.forEach((configToken) => configTokens.add(configToken)); - return configTokens; } /** * Get separate env config for the URL and connection details and return args to add to the config add command @@ -283,13 +273,6 @@ class Utils { static configJFrogServers(jfrogCredentials) { return __awaiter(this, void 0, void 0, function* () { let cliConfigCmd = ['config']; - let useOldConfig = Utils.useOldConfig(); - if (useOldConfig) { - // Add 'rt' prefix to the beginning of the config command - cliConfigCmd.unshift('rt'); - let version = core.getInput(Utils.CLI_VERSION_ARG); - core.warning('JFrog CLI ' + version + ' on Setup JFrog CLI GitHub Action is deprecated. Please use version 1.46.4 or above.'); - } for (let configToken of Utils.getConfigTokens()) { yield Utils.runCli(cliConfigCmd.concat('import', configToken)); } @@ -301,12 +284,7 @@ class Utils { } static removeJFrogServers() { return __awaiter(this, void 0, void 0, function* () { - if (Utils.useOldConfig()) { - yield Utils.runCli(['rt', 'c', 'clear', '--interactive=false']); - } - else { - yield Utils.runCli(['c', 'rm', '--quiet']); - } + yield Utils.runCli(['c', 'rm', '--quiet']); }); } static getArchitecture() { @@ -391,17 +369,6 @@ class Utils { } return; } - /** - * Return true if should use 'jfrog rt c' instead of 'jfrog c'. - * @returns true if should use 'jfrog rt c' instead of 'jfrog c'. - */ - static useOldConfig() { - let version = core.getInput(Utils.CLI_VERSION_ARG); - if (version === this.LATEST_CLI_VERSION) { - return false; - } - return (0, semver_1.lt)(version, this.NEW_CONFIG_CLI_VERSION); - } } exports.Utils = Utils; // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -411,14 +378,10 @@ Utils.DEFAULT_DOWNLOAD_DETAILS = { artifactoryUrl: 'https://releases.jfrog.io/artifactory', repository: 'jfrog-cli', }; -// The old JF_ARTIFACTORY_* prefix for Config Tokens -Utils.CONFIG_TOKEN_LEGACY_PREFIX = /^JF_ARTIFACTORY_.*$/; // The JF_ENV_* prefix for Config Tokens Utils.CONFIG_TOKEN_PREFIX = /^JF_ENV_.*$/; -// Since 1.45.0, 'jfrog rt c' command changed to 'jfrog c add' -Utils.NEW_CONFIG_CLI_VERSION = '1.45.0'; // Minimum JFrog CLI version supported -Utils.MIN_CLI_VERSION = '1.29.0'; +Utils.MIN_CLI_VERSION = '1.46.4'; // The value in "version" argument to set to get the latest JFrog CLI version Utils.LATEST_CLI_VERSION = 'latest'; // The value in the download URL to set to get the latest version diff --git a/package-lock.json b/package-lock.json index 7b2dcdad5..37819f6a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@jfrog/setup-jfrog-cli", - "version": "3.5.3", + "version": "4.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@jfrog/setup-jfrog-cli", - "version": "3.5.3", + "version": "4.0.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -30,8 +30,8 @@ "typescript": "^5.1.6" }, "engines": { - "node": ">=16.0.0", - "npm": ">=8.0.0" + "node": ">=20.0.0", + "npm": ">=10.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 5ecc059f9..9b9970789 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@jfrog/setup-jfrog-cli", - "version": "3.5.3", + "version": "4.0.0", "private": true, "description": "Setup JFrog CLI in GitHub Actions", "main": "lib/main.js", "engines": { - "npm": ">=8.0.0", - "node": ">=16.0.0" + "npm": ">=10.0.0", + "node": ">=20.0.0" }, "scripts": { "build": "tsc", diff --git a/src/utils.ts b/src/utils.ts index 0100772a3..346f34c2e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -17,14 +17,10 @@ export class Utils { repository: 'jfrog-cli', } as DownloadDetails; - // The old JF_ARTIFACTORY_* prefix for Config Tokens - private static readonly CONFIG_TOKEN_LEGACY_PREFIX: RegExp = /^JF_ARTIFACTORY_.*$/; // The JF_ENV_* prefix for Config Tokens private static readonly CONFIG_TOKEN_PREFIX: RegExp = /^JF_ENV_.*$/; - // Since 1.45.0, 'jfrog rt c' command changed to 'jfrog c add' - private static readonly NEW_CONFIG_CLI_VERSION: string = '1.45.0'; // Minimum JFrog CLI version supported - private static readonly MIN_CLI_VERSION: string = '1.29.0'; + private static readonly MIN_CLI_VERSION: string = '1.46.4'; // The value in "version" argument to set to get the latest JFrog CLI version private static readonly LATEST_CLI_VERSION: string = 'latest'; // The value in the download URL to set to get the latest version @@ -230,29 +226,12 @@ export class Utils { // Get Config Tokens created on your local machine using JFrog CLI. // The Tokens configured with JF_ENV_ environment variables. public static getConfigTokens(): Set { - let configTokens: Set = new Set( + return new Set( Object.keys(process.env) .filter((envKey) => envKey.match(Utils.CONFIG_TOKEN_PREFIX)) .filter((envKey) => process.env[envKey]) .map((envKey) => process.env[envKey]?.trim() || ''), ); - - let legacyConfigTokens: Set = new Set( - Object.keys(process.env) - .filter((envKey) => envKey.match(Utils.CONFIG_TOKEN_LEGACY_PREFIX)) - .filter((envKey) => process.env[envKey]) - .map((envKey) => process.env[envKey]?.trim() || ''), - ); - - if (legacyConfigTokens.size > 0) { - core.warning( - 'The "JF_ARTIFACTORY_" prefix for environment variables is deprecated and is expected to be removed in v3. ' + - 'Please use the "JF_ENV_" prefix instead. The environment variables value should not be changed.', - ); - } - - legacyConfigTokens.forEach((configToken) => configTokens.add(configToken)); - return configTokens; } /** @@ -311,13 +290,6 @@ export class Utils { public static async configJFrogServers(jfrogCredentials: JfrogCredentials) { let cliConfigCmd: string[] = ['config']; - let useOldConfig: boolean = Utils.useOldConfig(); - if (useOldConfig) { - // Add 'rt' prefix to the beginning of the config command - cliConfigCmd.unshift('rt'); - let version: string = core.getInput(Utils.CLI_VERSION_ARG); - core.warning('JFrog CLI ' + version + ' on Setup JFrog CLI GitHub Action is deprecated. Please use version 1.46.4 or above.'); - } for (let configToken of Utils.getConfigTokens()) { await Utils.runCli(cliConfigCmd.concat('import', configToken)); } @@ -329,11 +301,7 @@ export class Utils { } public static async removeJFrogServers() { - if (Utils.useOldConfig()) { - await Utils.runCli(['rt', 'c', 'clear', '--interactive=false']); - } else { - await Utils.runCli(['c', 'rm', '--quiet']); - } + await Utils.runCli(['c', 'rm', '--quiet']); } public static getArchitecture() { @@ -425,18 +393,6 @@ export class Utils { } return; } - - /** - * Return true if should use 'jfrog rt c' instead of 'jfrog c'. - * @returns true if should use 'jfrog rt c' instead of 'jfrog c'. - */ - private static useOldConfig(): boolean { - let version: string = core.getInput(Utils.CLI_VERSION_ARG); - if (version === this.LATEST_CLI_VERSION) { - return false; - } - return lt(version, this.NEW_CONFIG_CLI_VERSION); - } } export interface DownloadDetails { diff --git a/test/main.spec.ts b/test/main.spec.ts index 95b6cf73c..10fd16aa2 100644 --- a/test/main.spec.ts +++ b/test/main.spec.ts @@ -25,18 +25,7 @@ const V2_CONFIG_TOKEN: string = `eyJ2ZXJzaW9uIjoyLCJ1cmwiOiJodHRwOi8vMTI3LjAuMC4 zNsQzdqSXkzSmdudC1WQSIsInNlcnZlcklkIjoibG9jYWwifQ==`; beforeEach(() => { - [ - 'JF_ARTIFACTORY_1', - 'JF_ARTIFACTORY_2', - 'ARTIFACTORY_JF_1', - 'JF_ENV_1', - 'JF_ENV_2', - 'ENV_JF_1', - 'JF_ENV_LOCAL', - 'JF_USER', - 'JF_PASSWORD', - 'JF_ACCESS_TOKEN', - ].forEach((envKey) => { + ['JF_ENV_1', 'JF_ENV_2', 'ENV_JF_1', 'JF_ENV_LOCAL', 'JF_USER', 'JF_PASSWORD', 'JF_ACCESS_TOKEN'].forEach((envKey) => { delete process.env[envKey]; }); }); @@ -58,21 +47,6 @@ test('Get Config Tokens', async () => { expect(configTokens).toStrictEqual(new Set(['DUMMY_CONFIG_TOKEN_1', 'DUMMY_CONFIG_TOKEN_2'])); }); -test('Get legacy Config Tokens', async () => { - process.env['ARTIFACTORY_JF_1'] = 'ILLEGAL_CONFIG_TOKEN'; - expect(Utils.getConfigTokens().size).toBe(0); - - process.env['JF_ARTIFACTORY_1'] = 'DUMMY_CONFIG_TOKEN_1'; - expect(Utils.getConfigTokens()).toStrictEqual(new Set(['DUMMY_CONFIG_TOKEN_1'])); - - process.env['JF_ARTIFACTORY_2'] = 'DUMMY_CONFIG_TOKEN_2'; - expect(Utils.getConfigTokens()).toStrictEqual(new Set(['DUMMY_CONFIG_TOKEN_1', 'DUMMY_CONFIG_TOKEN_2'])); - - process.env['JF_ENV_1'] = 'DUMMY_CONFIG_TOKEN_1'; - process.env['JF_ENV_2'] = 'DUMMY_CONFIG_TOKEN_3'; - expect(Utils.getConfigTokens()).toStrictEqual(new Set(['DUMMY_CONFIG_TOKEN_1', 'DUMMY_CONFIG_TOKEN_2', 'DUMMY_CONFIG_TOKEN_3'])); -}); - describe('Collect credentials from environment variables test', () => { let cases: string[][] = [ // [JF_URL, JF_ACCESS_TOKEN, JF_USER, JF_PASSWORD]