From 7f2329d8c44fab393eb8d825cf4f933621d3d6f5 Mon Sep 17 00:00:00 2001 From: technote-space Date: Fri, 6 Mar 2020 06:55:23 +0000 Subject: [PATCH 1/7] chore: update npm dependencies --- package.json | 2 +- yarn.lock | 100 +++++++++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index ab8f0b7..e171d18 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "release-ga": "./bin/release-ga" }, "dependencies": { - "@technote-space/release-github-actions": "^3.0.5", + "@technote-space/release-github-actions": "^4.0.0", "commander": "^4.1.1", "cosmiconfig": "^6.0.0", "dotenv": "^8.2.0", diff --git a/yarn.lock b/yarn.lock index 6b20226..c30ea20 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@actions/core@^1.2.2": +"@actions/core@^1.2.2", "@actions/core@^1.2.3": version "1.2.3" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.3.tgz#e844b4fa0820e206075445079130868f95bfca95" integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w== @@ -31,17 +31,17 @@ "@babel/highlight" "^7.8.3" "@babel/core@^7.1.0", "@babel/core@^7.7.5": - version "7.8.6" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.8.6.tgz#27d7df9258a45c2e686b6f18b6c659e563aa4636" - integrity sha512-Sheg7yEJD51YHAvLEV/7Uvw95AeWqYPL3Vk3zGujJKIhJ+8oLw2ALaf3hbucILhKsgSoADOvtKRJuNVdcJkOrg== + version "7.8.7" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.8.7.tgz#b69017d221ccdeb203145ae9da269d72cf102f3b" + integrity sha512-rBlqF3Yko9cynC5CCFy6+K/w2N+Sq/ff2BPy+Krp7rHlABIr5epbA7OxVeKoMHB39LZOp1UY5SuLjy6uWi35yA== dependencies: "@babel/code-frame" "^7.8.3" - "@babel/generator" "^7.8.6" + "@babel/generator" "^7.8.7" "@babel/helpers" "^7.8.4" - "@babel/parser" "^7.8.6" + "@babel/parser" "^7.8.7" "@babel/template" "^7.8.6" "@babel/traverse" "^7.8.6" - "@babel/types" "^7.8.6" + "@babel/types" "^7.8.7" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.1" @@ -51,12 +51,12 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.8.6": - version "7.8.6" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.8.6.tgz#57adf96d370c9a63c241cd719f9111468578537a" - integrity sha512-4bpOR5ZBz+wWcMeVtcf7FbjcFzCp+817z2/gHNncIRcM9MmKzUhtWCYAq27RAfUrAFwb+OCG1s9WEaVxfi6cjg== +"@babel/generator@^7.8.6", "@babel/generator@^7.8.7": + version "7.8.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.8.7.tgz#870b3cf7984f5297998152af625c4f3e341400f7" + integrity sha512-DQwjiKJqH4C3qGiyQCAExJHoZssn49JTMJgZ8SANGgVFdkupcUhLOdkAeoC6kmHZCPfoDG5M0b6cFlSN5wW7Ew== dependencies: - "@babel/types" "^7.8.6" + "@babel/types" "^7.8.7" jsesc "^2.5.1" lodash "^4.17.13" source-map "^0.5.0" @@ -107,10 +107,10 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.7.5", "@babel/parser@^7.8.6": - version "7.8.6" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.8.6.tgz#ba5c9910cddb77685a008e3c587af8d27b67962c" - integrity sha512-trGNYSfwq5s0SgM1BMEB8hX3NDmO7EP2wsDGDexiaKMB92BaRpS+qZfpkMqUBhcsOTBwNy9B/jieo4ad/t/z2g== +"@babel/parser@^7.1.0", "@babel/parser@^7.7.5", "@babel/parser@^7.8.6", "@babel/parser@^7.8.7": + version "7.8.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.8.7.tgz#7b8facf95d25fef9534aad51c4ffecde1a61e26a" + integrity sha512-9JWls8WilDXFGxs0phaXAZgpxTZhSk/yOYH2hTHC0X1yC7Z78IJfvR1vJ+rmJKq3I35td2XzXzN6ZLYlna+r/A== "@babel/plugin-syntax-bigint@^7.0.0": version "7.8.3" @@ -127,11 +127,11 @@ "@babel/helper-plugin-utils" "^7.8.0" "@babel/runtime@^7.6.3": - version "7.8.4" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.8.4.tgz#d79f5a2040f7caa24d53e563aad49cbc05581308" - integrity sha512-neAp3zt80trRVBI1x0azq6c57aNBqYZH8KhMm3TaB7wEI5Q4A2SHfBHE8w9gOhI/lrqxtEbXZgQIrHP+wvSGwQ== + version "7.8.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.8.7.tgz#8fefce9802db54881ba59f90bb28719b4996324d" + integrity sha512-+AATMUFppJDw6aiR5NVPHqIQBlV/Pj8wY/EZH+lmvRdUo9xBaz/rF3alAwFJQavvKfeOlPE7oaaDHVbcySbCsg== dependencies: - regenerator-runtime "^0.13.2" + regenerator-runtime "^0.13.4" "@babel/template@^7.7.4", "@babel/template@^7.8.3", "@babel/template@^7.8.6": version "7.8.6" @@ -157,10 +157,10 @@ globals "^11.1.0" lodash "^4.17.13" -"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.8.3", "@babel/types@^7.8.6": - version "7.8.6" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.8.6.tgz#629ecc33c2557fcde7126e58053127afdb3e6d01" - integrity sha512-wqz7pgWMIrht3gquyEFPVXeXCti72Rm8ep9b5tQKz9Yg9LzJA3HxosF1SB3Kc81KD1A3XBkkVYtJvCKS2Z/QrA== +"@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.8.3", "@babel/types@^7.8.6", "@babel/types@^7.8.7": + version "7.8.7" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.8.7.tgz#1fc9729e1acbb2337d5b6977a63979b4819f5d1d" + integrity sha512-k2TreEHxFA4CjGkL+GYjRyx35W0Mr7DP5+9q6WMkyKXB+904bYmG40syjMFV0oLlhhFCwWl0vA0DyzTDkwAiJw== dependencies: esutils "^2.0.2" lodash "^4.17.13" @@ -629,16 +629,16 @@ "@actions/github" "^2.1.1" js-yaml "^3.13.1" -"@technote-space/release-github-actions@^3.0.5": - version "3.0.5" - resolved "https://registry.yarnpkg.com/@technote-space/release-github-actions/-/release-github-actions-3.0.5.tgz#1af9ddccbbfe7f56d186736982d8dbff44ced703" - integrity sha512-XVM+v1GAcKDsAsRQ4lT7THr85eZEegA2UVuv6GHR2KtbgYpPIW4WchrMEzy6NbQ5dHw6lsxZTcTuU4pqSBTrFQ== +"@technote-space/release-github-actions@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@technote-space/release-github-actions/-/release-github-actions-4.0.0.tgz#730132cf858be2085c0d5a2cee56db2d235ab175" + integrity sha512-MZlCQWB8CI3YSNECEXNMDG9nV/UhYlF93ieFaebYf1sfo/UvGIpA2dvBUpDZFz4qT2naLx+Rf7klKur+CjuUDg== dependencies: - "@actions/core" "^1.2.2" + "@actions/core" "^1.2.3" "@actions/github" "^2.1.1" "@technote-space/filter-github-action" "^0.2.5" "@technote-space/github-action-helper" "^1.2.2" - moment "^2.24.0" + memize "^1.0.5" "@types/babel__core@^7.1.0": version "7.1.6" @@ -1122,10 +1122,10 @@ braces@^3.0.1: dependencies: fill-range "^7.0.1" -browser-process-hrtime@^0.1.2: - version "0.1.3" - resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz#616f00faef1df7ec1b5bf9cfe2bdc3170f26c7b4" - integrity sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw== +browser-process-hrtime@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" + integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== browser-resolve@^1.11.3: version "1.11.3" @@ -2394,9 +2394,9 @@ ini@^1.3.4: integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== inquirer@^7.0.0: - version "7.0.5" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.0.5.tgz#fb95b238ba19966c1a1f55db53c3f0ce5c9e4275" - integrity sha512-6Z5cP+LAO0rzNE7xWjWtT84jxKa5ScLEGLgegPXeO3dGeU8lNe5Ii7SlXH6KVtLGlDuaEhsvsFjrjWjw8j5lFg== + version "7.0.6" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.0.6.tgz#ee4ff0ea7ecda5324656fe665878790f66df7d0c" + integrity sha512-7SVO4h+QIdMq6XcqIqrNte3gS5MzCCKZdsq9DO4PJziBFNYzP3PGFbDjgadDb//MCahzgjCxvQ/O2wa7kx9o4w== dependencies: ansi-escapes "^4.2.1" chalk "^3.0.0" @@ -3457,6 +3457,11 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +memize@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/memize/-/memize-1.0.5.tgz#51d89e8407643dbc8cab98c6d56b889f9a3954e3" + integrity sha512-Dm8Jhb5kiC4+ynYsVR4QDXKt+o2dfqGuY4hE2x+XlXZkdndlT80bJxfcMv5QGp/FCy6MhG7f5ElpmKPFKOSEpg== + meow@5.0.0, meow@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" @@ -3566,11 +3571,6 @@ mkdirp@0.x, mkdirp@^0.5.1: dependencies: minimist "0.0.8" -moment@^2.24.0: - version "2.24.0" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" - integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -4118,10 +4118,10 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== -regenerator-runtime@^0.13.2: - version "0.13.3" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz#7cf6a77d8f5c6f60eb73c5fc1955b2ceb01e6bf5" - integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw== +regenerator-runtime@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz#e96bf612a3362d12bb69f7e8f74ffeab25c7ac91" + integrity sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g== regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" @@ -5121,11 +5121,11 @@ verror@1.10.0: extsprintf "^1.2.0" w3c-hr-time@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045" - integrity sha1-gqwr/2PZUOqeMYmlimViX+3xkEU= + version "1.0.2" + resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd" + integrity sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ== dependencies: - browser-process-hrtime "^0.1.2" + browser-process-hrtime "^1.0.0" w3c-xmlserializer@^1.1.2: version "1.1.2" From 13551ca283524c9e483256c20c6e85c82bbbf7d7 Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 15:56:20 +0900 Subject: [PATCH 2/7] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e171d18..52782de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/release-github-actions-cli", - "version": "1.4.1", + "version": "1.4.2", "description": "Release GitHub Actions Cli", "author": { "name": "Technote", From 688c90f411e871eda3fd1f1d5642a47df5697a98 Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 17:04:20 +0900 Subject: [PATCH 3/7] fix: update library --- __tests__/config.test.ts | 46 ++++++++++++--------- __tests__/env.test.ts | 4 ++ __tests__/index.test.ts | 87 ++++++++++++++++++++++------------------ __tests__/misc.test.ts | 4 ++ src/config.ts | 12 +++++- src/index.ts | 2 +- src/wrapper.ts | 28 ++++++++----- 7 files changed, 112 insertions(+), 71 deletions(-) diff --git a/__tests__/config.test.ts b/__tests__/config.test.ts index 18ee6fb..308c776 100644 --- a/__tests__/config.test.ts +++ b/__tests__/config.test.ts @@ -1,8 +1,12 @@ /* eslint-disable no-magic-numbers */ import { resolve } from 'path'; +import { getParams } from '@technote-space/release-github-actions/lib/utils/misc'; import { normalizeConfigKey, normalizeConfigKeys, getActionDefaultInputs, getConfig } from '../src/config'; const fixturesDir = resolve(__dirname, 'fixtures'); +beforeEach(() => { + getParams.clear(); +}); describe('normalizeConfigKey', () => { it('should normalize config key', () => { @@ -32,18 +36,19 @@ describe('normalizeConfigKeys', () => { describe('getActionDefaultInputs', () => { it('should get inputs', () => { expect(getActionDefaultInputs()).toEqual({ - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '3', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', @@ -56,18 +61,19 @@ describe('getConfig', () => { it('should get config 1', () => { expect(getConfig(resolve(fixturesDir, 'test7'), undefined)).toEqual({ 'inputs': { - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '5', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', @@ -82,18 +88,19 @@ describe('getConfig', () => { it('should get config 2', () => { expect(getConfig(resolve(fixturesDir, 'test8'), false)).toEqual({ 'inputs': { - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '3', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', @@ -107,18 +114,19 @@ describe('getConfig', () => { it('should get config 3', () => { expect(getConfig(resolve(fixturesDir, 'test9'), true)).toEqual({ 'inputs': { - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}, gh-actions', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '3', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', @@ -132,18 +140,19 @@ describe('getConfig', () => { it('should get config 4', () => { expect(getConfig(resolve(fixturesDir, 'test10'), undefined)).toEqual({ 'inputs': { - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '3', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', @@ -157,18 +166,19 @@ describe('getConfig', () => { it('should get config 5', () => { expect(getConfig(resolve(fixturesDir, 'test12'), undefined)).toEqual({ 'inputs': { - 'BRANCH_NAME': 'gh-actions', + 'BRANCH_NAME': 'releases/${MAJOR}', 'BUILD_COMMAND': '', - 'BUILD_COMMAND_TARGET': '', + 'BUILD_COMMAND_TARGET': 'build,production,prod,package', 'CLEAN_TARGETS': '.[!.]*,__tests__,src,*.js,*.ts,*.json,*.lock,*.yml,*.yaml', 'CLEAN_TEST_TAG': 'false', 'COMMIT_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com', - 'COMMIT_MESSAGE': 'feat: Build for release', + 'COMMIT_MESSAGE': 'feat: build for release', 'COMMIT_NAME': 'github-actions[bot]', 'CREATE_MAJOR_VERSION_TAG': 'true', 'CREATE_MINOR_VERSION_TAG': 'true', 'CREATE_PATCH_VERSION_TAG': 'true', 'FETCH_DEPTH': '3', + 'GITHUB_TOKEN': '${{ github.token }}', 'ORIGINAL_TAG_PREFIX': '', 'OUTPUT_BUILD_INFO_FILENAME': '', 'PACKAGE_MANAGER': '', diff --git a/__tests__/env.test.ts b/__tests__/env.test.ts index d388d56..4520ae4 100644 --- a/__tests__/env.test.ts +++ b/__tests__/env.test.ts @@ -1,9 +1,13 @@ /* eslint-disable no-magic-numbers */ import { resolve } from 'path'; import { testEnv } from '@technote-space/github-action-test-helper'; +import { getParams } from '@technote-space/release-github-actions/lib/utils/misc'; import { setEnv, loadTokenFromEnv } from '../src/env'; const fixturesDir = resolve(__dirname, 'fixtures'); +beforeEach(() => { + getParams.clear(); +}); describe('setEnv', () => { testEnv(); diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index cd385de..c0281d7 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -6,9 +6,11 @@ import { testChildProcess, spyOnExec, execCalledWith, - testFs, setChildProcessParams, + testFs, + setChildProcessParams, } from '@technote-space/github-action-test-helper'; import { Logger } from '@technote-space/github-action-helper'; +import { getParams } from '@technote-space/release-github-actions/lib/utils/misc'; import commander from 'commander'; import { execute } from '../src'; @@ -23,6 +25,7 @@ beforeEach(() => { delete commander.branch; delete commander.workspace; delete commander.dryRun; + getParams.clear(); }); describe('execute', () => { @@ -97,10 +100,10 @@ describe('execute', () => { `rm -rdf ${cwd}/__tests__/tmp/.work/build ${cwd}/__tests__/tmp/.work/push`, 'git init \'.\'', 'git remote add origin \'https://test-owner:token@github.com/test-owner/test-repo.git\' > /dev/null 2>&1 || :', - 'git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\' || :', - 'git checkout -b gh-actions origin/gh-actions || :', + 'git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\' || :', + 'git checkout -b releases/v1 origin/releases/v1 || :', 'git init \'.\'', - 'git checkout --orphan gh-actions', + 'git checkout --orphan releases/v1', `rsync -ac -C '--filter=:- .gitignore' --exclude '.git' --exclude '.work' --exclude '.github' --delete './' '${cwd}/__tests__/tmp/.work/build'`, 'rm -rdf node_modules', 'npm install --production', @@ -119,7 +122,7 @@ describe('execute', () => { 'git config \'user.name\' \'github-actions[bot]\'', 'git config \'user.email\' \'41898282+github-actions[bot]@users.noreply.github.com\'', 'git add --all', - 'git commit --allow-empty -qm \'feat: Build for release\'', + 'git commit --allow-empty -qm \'feat: build for release\'', 'git show \'--stat-count=10\' HEAD', 'git tag', 'git tag -d stdout > /dev/null 2>&1', @@ -133,7 +136,7 @@ describe('execute', () => { 'git tag \'test/v1.2.3\'', 'git tag \'test/v1.2\'', 'git tag test/v1', - 'git push --tags \'https://test-owner:token@github.com/test-owner/test-repo.git\' \'gh-actions:refs/heads/gh-actions\' > /dev/null 2>&1 || :', + 'git push --tags \'https://test-owner:token@github.com/test-owner/test-repo.git\' \'releases/v1:refs/heads/releases/v1\' > /dev/null 2>&1 || :', ]); stdoutCalledWith(mockStdout, [ '[command]rm -rdf ', @@ -142,19 +145,19 @@ describe('execute', () => { '[command]git init \'.\'', ' >> stdout', '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\'', + '[command]git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\'', ' >> stdout', '::endgroup::', - '::group::Switching branch to [gh-actions]...', - '[command]git checkout -b gh-actions origin/gh-actions', + '::group::Switching branch to [releases/v1]...', + '[command]git checkout -b releases/v1 origin/releases/v1', ' >> stdout', - '> remote branch gh-actions not found.', + '> remote branch releases/v1 not found.', '> now branch: ', '::endgroup::', - '::group::Initializing local git repo [gh-actions]...', + '::group::Initializing local git repo [releases/v1]...', '[command]git init \'.\'', ' >> stdout', - '[command]git checkout --orphan gh-actions', + '[command]git checkout --orphan releases/v1', ' >> stdout', '::endgroup::', '::group::Copying current source to build directory...', @@ -194,12 +197,12 @@ describe('execute', () => { ' >> stdout', '[command]git add --all', ' >> stdout', - '[command]git commit --allow-empty -qm \'feat: Build for release\'', + '[command]git commit --allow-empty -qm \'feat: build for release\'', ' >> stdout', '[command]git show \'--stat-count=10\' HEAD', ' >> stdout', '::endgroup::', - '::group::Pushing to test-owner/test-repo@gh-actions (tag: test/v1.2.3)...', + '::group::Pushing to test-owner/test-repo@releases/v1 (tag: test/v1.2.3)...', '[command]git fetch origin --tags', '[command]git push origin --delete tags/test/v1.2.3', '[command]git push origin --delete tags/test/v1.2', @@ -216,7 +219,7 @@ describe('execute', () => { ' >> stdout', '[command]git tag test/v1', ' >> stdout', - '[command]git push --tags origin gh-actions:refs/heads/gh-actions', + '[command]git push --tags origin releases/v1:refs/heads/releases/v1', ]); }); @@ -253,10 +256,10 @@ describe('execute', () => { `rm -rdf ${cwd}/__tests__/tmp/.work/build ${cwd}/__tests__/tmp/.work/push`, 'git init \'.\'', 'git remote add origin \'https://test-owner:token@github.com/test-owner/test-repo.git\' > /dev/null 2>&1 || :', - 'git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\' || :', - 'git checkout -b gh-actions origin/gh-actions || :', + 'git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\' || :', + 'git checkout -b releases/v1 origin/releases/v1 || :', 'git init \'.\'', - 'git checkout --orphan gh-actions', + 'git checkout --orphan releases/v1', `rsync -ac -C '--filter=:- .gitignore' --exclude '.git' --exclude '.work' --exclude '.github' --delete './' '${cwd}/__tests__/tmp/.work/build'`, 'rm -rdf node_modules', 'npm install --production', @@ -275,7 +278,7 @@ describe('execute', () => { 'git config \'user.name\' \'github-actions[bot]\'', 'git config \'user.email\' \'41898282+github-actions[bot]@users.noreply.github.com\'', 'git add --all', - 'git commit --allow-empty -qm \'feat: Build for release\'', + 'git commit --allow-empty -qm \'feat: build for release\'', 'git show \'--stat-count=10\' HEAD', 'git tag', 'git tag -d v1 \'v1.2.3\' \'1.2\' > /dev/null 2>&1', @@ -289,7 +292,9 @@ describe('execute', () => { 'git tag \'test/v1.2.4\'', 'git tag \'test/v1.2\'', 'git tag test/v1', - 'git push --tags \'https://test-owner:token@github.com/test-owner/test-repo.git\' \'gh-actions:refs/heads/gh-actions\' > /dev/null 2>&1 || :', + 'git push --tags \'https://test-owner:token@github.com/test-owner/test-repo.git\' \'releases/v1:refs/heads/releases/v1\' > /dev/null 2>&1 || :', + 'git checkout -b gh-actions', + 'git push --force \'https://test-owner:token@github.com/test-owner/test-repo.git\' \'gh-actions:refs/heads/gh-actions\' > /dev/null 2>&1 || :', ]); stdoutCalledWith(mockStdout, [ '[command]git tag', @@ -300,16 +305,16 @@ describe('execute', () => { '::group::Fetching...', '[command]git init \'.\'', '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\'', + '[command]git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\'', '::endgroup::', - '::group::Switching branch to [gh-actions]...', - '[command]git checkout -b gh-actions origin/gh-actions', - '> remote branch gh-actions not found.', + '::group::Switching branch to [releases/v1]...', + '[command]git checkout -b releases/v1 origin/releases/v1', + '> remote branch releases/v1 not found.', '> now branch: ', '::endgroup::', - '::group::Initializing local git repo [gh-actions]...', + '::group::Initializing local git repo [releases/v1]...', '[command]git init \'.\'', - '[command]git checkout --orphan gh-actions', + '[command]git checkout --orphan releases/v1', '::endgroup::', '::group::Copying current source to build directory...', '[command]rsync -ac -C \'--filter=:- .gitignore\' --exclude \'.git\' --exclude \'.work\' --exclude \'.github\' --delete \'./\' \'\'', @@ -333,10 +338,10 @@ describe('execute', () => { '[command]git config \'user.name\' \'github-actions[bot]\'', '[command]git config \'user.email\' \'41898282+github-actions[bot]@users.noreply.github.com\'', '[command]git add --all', - '[command]git commit --allow-empty -qm \'feat: Build for release\'', + '[command]git commit --allow-empty -qm \'feat: build for release\'', '[command]git show \'--stat-count=10\' HEAD', '::endgroup::', - '::group::Pushing to test-owner/test-repo@gh-actions (tag: test/v1.2.4)...', + '::group::Pushing to test-owner/test-repo@releases/v1 (tag: test/v1.2.4)...', '[command]git fetch origin --tags', '[command]git push origin --delete tags/test/v1.2.4', '[command]git push origin --delete tags/test/v1.2', @@ -347,7 +352,9 @@ describe('execute', () => { '[command]git tag \'test/v1.2.4\'', '[command]git tag \'test/v1.2\'', '[command]git tag test/v1', - '[command]git push --tags origin gh-actions:refs/heads/gh-actions', + '[command]git push --tags origin releases/v1:refs/heads/releases/v1', + '[command]git checkout -b gh-actions', + '[command]git push --force origin gh-actions:refs/heads/gh-actions', ]); }); @@ -377,10 +384,10 @@ describe('execute', () => { `rm -rdf ${cwd}/__tests__/tmp/.work/build ${cwd}/__tests__/tmp/.work/push`, 'git init \'.\'', 'git remote add origin \'https://test-owner:token@github.com/test-owner/test-repo.git\' > /dev/null 2>&1 || :', - 'git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\' || :', - 'git checkout -b gh-actions origin/gh-actions || :', + 'git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\' || :', + 'git checkout -b releases/v1 origin/releases/v1 || :', 'git init \'.\'', - 'git checkout --orphan gh-actions', + 'git checkout --orphan releases/v1', 'git init \'.\'', 'git remote add origin \'https://test-owner:token@github.com/test-owner/test-repo.git\' > /dev/null 2>&1 || :', 'git fetch --no-tags origin \'refs/heads/release/v1.2.3:refs/remotes/origin/release/v1.2.3\' || :', @@ -402,7 +409,7 @@ describe('execute', () => { 'git config \'user.name\' \'github-actions[bot]\'', 'git config \'user.email\' \'41898282+github-actions[bot]@users.noreply.github.com\'', 'git add --all', - 'git commit --allow-empty -qm \'feat: Build for release\'', + 'git commit --allow-empty -qm \'feat: build for release\'', 'git show \'--stat-count=10\' HEAD', ]); stdoutCalledWith(mockStdout, [ @@ -412,19 +419,19 @@ describe('execute', () => { '[command]git init \'.\'', ' >> stdout', '[command]git remote add origin', - '[command]git fetch --no-tags origin \'refs/heads/gh-actions:refs/remotes/origin/gh-actions\'', + '[command]git fetch --no-tags origin \'refs/heads/releases/v1:refs/remotes/origin/releases/v1\'', ' >> stdout', '::endgroup::', - '::group::Switching branch to [gh-actions]...', - '[command]git checkout -b gh-actions origin/gh-actions', + '::group::Switching branch to [releases/v1]...', + '[command]git checkout -b releases/v1 origin/releases/v1', ' >> stdout', - '> remote branch gh-actions not found.', + '> remote branch releases/v1 not found.', '> now branch: ', '::endgroup::', - '::group::Initializing local git repo [gh-actions]...', + '::group::Initializing local git repo [releases/v1]...', '[command]git init \'.\'', ' >> stdout', - '[command]git checkout --orphan gh-actions', + '[command]git checkout --orphan releases/v1', ' >> stdout', '::endgroup::', '::group::Cloning the remote repo for build...', @@ -469,7 +476,7 @@ describe('execute', () => { ' >> stdout', '[command]git add --all', ' >> stdout', - '[command]git commit --allow-empty -qm \'feat: Build for release\'', + '[command]git commit --allow-empty -qm \'feat: build for release\'', ' >> stdout', '[command]git show \'--stat-count=10\' HEAD', ' >> stdout', diff --git a/__tests__/misc.test.ts b/__tests__/misc.test.ts index e7c9994..97920cc 100644 --- a/__tests__/misc.test.ts +++ b/__tests__/misc.test.ts @@ -1,10 +1,14 @@ /* eslint-disable no-magic-numbers */ import { resolve } from 'path'; import { testEnv, testFs, setChildProcessParams } from '@technote-space/github-action-test-helper'; +import { getParams } from '@technote-space/release-github-actions/lib/utils/misc'; import { getRepository, getContext, getContextArgs, getGitHelper } from '../src/misc'; const fixturesDir = resolve(__dirname, 'fixtures'); testFs(true); +beforeEach(() => { + getParams.clear(); +}); describe('getRepository', () => { it('should throw error 1', () => { diff --git a/src/config.ts b/src/config.ts index 1f39a4a..6466db6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -48,5 +48,15 @@ export const getConfig = (dir: string, isTest: boolean | undefined): Config | ne } } - return {...config, inputs: {...getActionDefaultInputs(), ...{TEST_TAG_PREFIX: isTest ? 'test/' : ''}, ...normalizeConfigKeys(config.inputs ?? config.INPUTS ?? {})}}; + return { + ...config, + inputs: { + ...getActionDefaultInputs(), + ...{ + TEST_TAG_PREFIX: isTest ? 'test/' : '', + BRANCH_NAME: isTest ? 'releases/${MAJOR}, gh-actions' : 'releases/${MAJOR}', + }, + ...normalizeConfigKeys(config.inputs ?? config.INPUTS ?? {}), + }, + }; }; diff --git a/src/index.ts b/src/index.ts index d169465..fc51950 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,7 +33,7 @@ export const execute = async(): Promise => { } await prepare(helper, args); - await commit(helper); + await commit(helper, args); if (!commander.dryRun) { await push(helper, args); } diff --git a/src/wrapper.ts b/src/wrapper.ts index 07fbe00..9719b1a 100644 --- a/src/wrapper.ts +++ b/src/wrapper.ts @@ -9,7 +9,7 @@ import { ContextArgs } from './types'; export const isValidContext = (args: ContextArgs): boolean => misc.isValidContext(getContext(args)); export const prepareFiles = async(logger: Logger, com: Command, helper: GitHelper, args: ContextArgs, context: Context): Promise => { - const {buildDir, pushDir} = misc.getParams(); + const {buildDir, pushDir} = misc.getParams(context); mkdirSync(buildDir, {recursive: true}); if (args.branch) { @@ -42,22 +42,28 @@ export const prepareFiles = async(logger: Logger, com: Command, helper: GitHelpe export const prepare = async(helper: GitHelper, args: ContextArgs): Promise => { const context = getContext(args); - const {buildDir, pushDir} = misc.getParams(); - const logger = new Logger(command.replaceDirectory); + const {buildDir, pushDir} = misc.getParams(context); + const logger = new Logger(command.replaceDirectory(context)); const com = new Command(logger); await com.execAsync({command: `rm -rdf ${buildDir} ${pushDir}`}); - await command.clone(helper, context); - await command.checkBranch(await helper.getCurrentBranchName(misc.getParams().pushDir), helper); + await command.clone(logger, helper, context); + await command.checkBranch(await helper.getCurrentBranchName(pushDir), logger, helper, context); await prepareFiles(logger, com, helper, args, context); - await command.createBuildInfoFile(context); - await command.copyFiles(); + await command.createBuildInfoFile(logger, context); + await command.copyFiles(logger, com, context); }; -export const commit = async(helper: GitHelper): Promise => { - await command.config(helper); - await command.commit(helper); +export const commit = async(helper: GitHelper, args: ContextArgs): Promise => { + const context = getContext(args); + const logger = new Logger(command.replaceDirectory(context)); + await command.config(logger, helper, context); + await command.commit(helper, context); }; -export const push = async(helper: GitHelper, args: ContextArgs): Promise => command.push(helper, getContext(args)); +export const push = async(helper: GitHelper, args: ContextArgs): Promise => { + const context = getContext(args); + const logger = new Logger(command.replaceDirectory(context)); + await command.push(logger, helper, getContext(args)); +}; From 1db26cad419258f9ca0e368155ac5804a8209719 Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 17:09:05 +0900 Subject: [PATCH 4/7] feat: dump version (#52) --- __tests__/index.test.ts | 1 + src/misc.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts index c0281d7..9cfd3d6 100644 --- a/__tests__/index.test.ts +++ b/__tests__/index.test.ts @@ -301,6 +301,7 @@ describe('execute', () => { ' >> v1', ' >> v1.2.3', ' >> 1.2', + '> version: v1.2.4', '[command]rm -rdf ', '::group::Fetching...', '[command]git init \'.\'', diff --git a/src/misc.ts b/src/misc.ts index 05201c5..74953b1 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -28,7 +28,9 @@ export const getContextArgs = async(helper: GitHelper, tagName: string | undefin throw new Error(' is required.'); } - return {...config, tagName: config.inputs.TEST_TAG_PREFIX + await helper.getNewPatchVersion(dir), branch}; + const version = await helper.getNewPatchVersion(dir); + (new Logger()).info('version: %s', version); + return {...config, tagName: config.inputs.TEST_TAG_PREFIX + version, branch}; } return {...config, tagName, branch}; From 1d8cb2cd6b0241584ad93e80b18e9f0a2ff844ad Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 17:11:28 +0900 Subject: [PATCH 5/7] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52782de..a1f1336 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/release-github-actions-cli", - "version": "1.4.2", + "version": "1.5.0", "description": "Release GitHub Actions Cli", "author": { "name": "Technote", From 2331172b8fe0dc63e8d5b5ff9707cfbb81e69f37 Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 17:11:50 +0900 Subject: [PATCH 6/7] feat: update package version From 07ef2982670901eb018d3cdb9432b58857b3ef74 Mon Sep 17 00:00:00 2001 From: Technote Date: Fri, 6 Mar 2020 17:19:22 +0900 Subject: [PATCH 7/7] chore: tweaks --- README.ja.md | 3 +-- README.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.ja.md b/README.ja.md index e3af389..55c927d 100644 --- a/README.ja.md +++ b/README.ja.md @@ -7,8 +7,7 @@ *Read this in other languages: [English](README.md), [日本語](README.ja.md).* -`Release GitHub Actions` の CLIツール -[Release GitHub Actions](https://github.com/technote-space/release-github-actions) をラップしたものです。 +[Release GitHub Actions](https://github.com/technote-space/release-github-actions) の CLIツール ## Table of Contents diff --git a/README.md b/README.md index c168ed6..58660fd 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ *Read this in other languages: [English](README.md), [日本語](README.ja.md).* -CLI tool of `Release GitHub Actions`. -Wrapper of [Release GitHub Actions](https://github.com/technote-space/release-github-actions). +CLI tool of [Release GitHub Actions](https://github.com/technote-space/release-github-actions). ## Table of Contents