revert: feat: create annotated tags
This reverts commit 4d581fc140dda99065542872d125cf27fb24798f.
This commit is contained in:
parent
d120eaea8b
commit
0629f3cd8a
4
index.js
4
index.js
@ -106,7 +106,7 @@ async function run(context, plugins) {
|
||||
nextRelease.notes = await plugins.generateNotes({...context, commits, lastRelease, nextRelease});
|
||||
|
||||
logger.log('Create tag %s', nextRelease.gitTag);
|
||||
await tag(nextRelease, {cwd, env});
|
||||
await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env});
|
||||
await push(options.repositoryUrl, {cwd, env});
|
||||
context.branch.tags.push({
|
||||
version: nextRelease.version,
|
||||
@ -170,7 +170,7 @@ async function run(context, plugins) {
|
||||
logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
|
||||
} else {
|
||||
// Create the tag before calling the publish plugins as some require the tag to exists
|
||||
await tag(nextRelease, {cwd, env});
|
||||
await tag(nextRelease.gitTag, nextRelease.gitHead, {cwd, env});
|
||||
await push(options.repositoryUrl, {cwd, env});
|
||||
logger.success(`Created tag ${nextRelease.gitTag}`);
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ const SECRET_REPLACEMENT = '[secure]';
|
||||
|
||||
const SECRET_MIN_SIZE = 5;
|
||||
|
||||
const TAG_MESSAGE_FORMAT = `release \${version}`;
|
||||
|
||||
module.exports = {
|
||||
RELEASE_TYPE,
|
||||
FIRST_RELEASE,
|
||||
@ -25,5 +23,4 @@ module.exports = {
|
||||
RELEASE_NOTES_SEPARATOR,
|
||||
SECRET_REPLACEMENT,
|
||||
SECRET_MIN_SIZE,
|
||||
TAG_MESSAGE_FORMAT,
|
||||
};
|
||||
|
14
lib/git.js
14
lib/git.js
@ -1,9 +1,8 @@
|
||||
const {matches, pick, memoize, template} = require('lodash');
|
||||
const {matches, pick, memoize} = require('lodash');
|
||||
const gitLogParser = require('git-log-parser');
|
||||
const getStream = require('get-stream');
|
||||
const execa = require('execa');
|
||||
const debug = require('debug')('semantic-release:git');
|
||||
const {TAG_MESSAGE_FORMAT} = require('./definitions/constants');
|
||||
|
||||
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
|
||||
|
||||
@ -223,17 +222,14 @@ async function verifyAuth(repositoryUrl, branch, execaOpts) {
|
||||
/**
|
||||
* Tag the commit head on the local repository.
|
||||
*
|
||||
* @param {Object} release The release associated with the tag.
|
||||
* @param {String} tagName The name of the tag.
|
||||
* @param {String} ref The Git reference to tag.
|
||||
* @param {Object} [execaOpts] Options to pass to `execa`.
|
||||
*
|
||||
* @throws {Error} if the tag creation failed.
|
||||
*/
|
||||
async function tag(release, execaOpts) {
|
||||
await execa(
|
||||
'git',
|
||||
['tag', release.gitTag, release.gitHead, '-a', '-m', template(TAG_MESSAGE_FORMAT)(release)],
|
||||
execaOpts
|
||||
);
|
||||
async function tag(tagName, ref, execaOpts) {
|
||||
await execa('git', ['tag', tagName, ref], execaOpts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,7 +183,7 @@ test('Add tag on head commit', async t => {
|
||||
const {cwd} = await gitRepo();
|
||||
const commits = await gitCommits(['Test commit'], {cwd});
|
||||
|
||||
await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd});
|
||||
await tag('tag_name', 'HEAD', {cwd});
|
||||
|
||||
await t.is(await gitCommitTag(commits[0].hash, {cwd}), 'tag_name');
|
||||
});
|
||||
@ -193,7 +193,7 @@ test('Push tag to remote repository', async t => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
const commits = await gitCommits(['Test commit'], {cwd});
|
||||
|
||||
await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd});
|
||||
await tag('tag_name', 'HEAD', {cwd});
|
||||
await push(repositoryUrl, {cwd});
|
||||
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash);
|
||||
@ -207,7 +207,7 @@ test('Push tag to remote repository with remote branch ahead', async t => {
|
||||
await gitCommits(['Second'], {cwd: tmpRepo});
|
||||
await gitPush('origin', 'master', {cwd: tmpRepo});
|
||||
|
||||
await tag({gitTag: 'tag_name', gitHead: 'HEAD', version: '1.0.0'}, {cwd});
|
||||
await tag('tag_name', 'HEAD', {cwd});
|
||||
await push(repositoryUrl, {cwd});
|
||||
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, 'tag_name', {cwd}), commits[0].hash);
|
||||
|
@ -195,7 +195,7 @@ export function gitTagHead(tagName, execaOpts) {
|
||||
* @return {String} The sha of the commit associated with `tagName` on the remote repository.
|
||||
*/
|
||||
export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
|
||||
return (await execa.stdout('git', ['ls-remote', repositoryUrl, `${tagName}^{}`], execaOpts))
|
||||
return (await execa.stdout('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts))
|
||||
.split('\n')
|
||||
.filter(tag => Boolean(tag))
|
||||
.map(tag => tag.match(/^(\S+)/)[1])[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user