Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ed6213977 | ||
|
|
8051294ffd | ||
|
|
95a0456a85 | ||
|
|
038e640d5e | ||
|
|
f3f9d1ef58 |
@@ -46,9 +46,7 @@ async function run(context, plugins) {
|
|||||||
|
|
||||||
if (ciBranch !== options.branch) {
|
if (ciBranch !== options.branch) {
|
||||||
logger.log(
|
logger.log(
|
||||||
`This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${
|
`This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${options.branch}, therefore a new version won’t be published.`
|
||||||
options.branch
|
|
||||||
}, therefore a new version won’t be published.`
|
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -3,16 +3,6 @@ const {isNil} = require('lodash');
|
|||||||
const hostedGitInfo = require('hosted-git-info');
|
const hostedGitInfo = require('hosted-git-info');
|
||||||
const {verifyAuth} = require('./git');
|
const {verifyAuth} = require('./git');
|
||||||
|
|
||||||
const GIT_TOKENS = {
|
|
||||||
GIT_CREDENTIALS: undefined,
|
|
||||||
GH_TOKEN: undefined,
|
|
||||||
GITHUB_TOKEN: undefined,
|
|
||||||
GL_TOKEN: 'gitlab-ci-token:',
|
|
||||||
GITLAB_TOKEN: 'gitlab-ci-token:',
|
|
||||||
BB_TOKEN: 'x-token-auth:',
|
|
||||||
BITBUCKET_TOKEN: 'x-token-auth:',
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the the git repository URL to use to push, either:
|
* Determine the the git repository URL to use to push, either:
|
||||||
* - The `repositoryUrl` as is if allowed to push
|
* - The `repositoryUrl` as is if allowed to push
|
||||||
@@ -25,6 +15,18 @@ const GIT_TOKENS = {
|
|||||||
* @return {String} The formatted Git repository URL.
|
* @return {String} The formatted Git repository URL.
|
||||||
*/
|
*/
|
||||||
module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => {
|
module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => {
|
||||||
|
const GIT_TOKENS = {
|
||||||
|
GIT_CREDENTIALS: undefined,
|
||||||
|
GH_TOKEN: undefined,
|
||||||
|
// GitHub Actions require the "x-access-token:" prefix for git access
|
||||||
|
// https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation
|
||||||
|
GITHUB_TOKEN: isNil(env.GITHUB_ACTION) ? undefined : 'x-access-token:',
|
||||||
|
GL_TOKEN: 'gitlab-ci-token:',
|
||||||
|
GITLAB_TOKEN: 'gitlab-ci-token:',
|
||||||
|
BB_TOKEN: 'x-token-auth:',
|
||||||
|
BITBUCKET_TOKEN: 'x-token-auth:',
|
||||||
|
};
|
||||||
|
|
||||||
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
|
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
|
||||||
const {protocol, ...parsed} = parse(repositoryUrl);
|
const {protocol, ...parsed} = parse(repositoryUrl);
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -3,6 +3,14 @@
|
|||||||
"description": "Automated semver compliant package publishing",
|
"description": "Automated semver compliant package publishing",
|
||||||
"version": "0.0.0-development",
|
"version": "0.0.0-development",
|
||||||
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
||||||
|
"ava": {
|
||||||
|
"files": [
|
||||||
|
"test/**/*.test.js"
|
||||||
|
],
|
||||||
|
"helpers": [
|
||||||
|
"test/helpers/**/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"semantic-release": "bin/semantic-release.js"
|
"semantic-release": "bin/semantic-release.js"
|
||||||
},
|
},
|
||||||
@@ -27,7 +35,7 @@
|
|||||||
"aggregate-error": "^3.0.0",
|
"aggregate-error": "^3.0.0",
|
||||||
"cosmiconfig": "^5.0.1",
|
"cosmiconfig": "^5.0.1",
|
||||||
"debug": "^4.0.0",
|
"debug": "^4.0.0",
|
||||||
"env-ci": "^3.0.0",
|
"env-ci": "^4.0.0",
|
||||||
"execa": "^1.0.0",
|
"execa": "^1.0.0",
|
||||||
"figures": "^3.0.0",
|
"figures": "^3.0.0",
|
||||||
"find-versions": "^3.0.0",
|
"find-versions": "^3.0.0",
|
||||||
@@ -47,7 +55,7 @@
|
|||||||
"yargs": "^13.1.0"
|
"yargs": "^13.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^1.3.1",
|
"ava": "^2.0.0",
|
||||||
"clear-module": "^3.0.0",
|
"clear-module": "^3.0.0",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"commitizen": "^3.0.0",
|
"commitizen": "^3.0.0",
|
||||||
|
|||||||
@@ -244,6 +244,19 @@ test('Return the "https" formatted URL if "gitCredentials" is defined with "BITB
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Return the "https" formatted URL if "GITHUB_ACTION" is set', async t => {
|
||||||
|
const {cwd} = await gitRepo();
|
||||||
|
|
||||||
|
t.is(
|
||||||
|
await getAuthUrl({
|
||||||
|
cwd,
|
||||||
|
env: {...env, GITHUB_ACTION: 'foo', GITHUB_TOKEN: 'token'},
|
||||||
|
options: {branch: 'master', repositoryUrl: 'git@host.null:owner/repo.git'},
|
||||||
|
}),
|
||||||
|
'https://x-access-token:token@host.null/owner/repo.git'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('Handle "https" URL with group and subgroup, with "GIT_CREDENTIALS"', async t => {
|
test('Handle "https" URL with group and subgroup, with "GIT_CREDENTIALS"', async t => {
|
||||||
const {cwd} = await gitRepo();
|
const {cwd} = await gitRepo();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user