Skip to content

Commit

Permalink
Try with head sha
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirakis committed Dec 4, 2024
1 parent de60dce commit 777f68a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
"description": "When tagging a release, include `v` in the tag. Defaults to `false`.",
"type": "boolean"
},
"tag-head-sha": {
"description": "Tag head sha of the PR with the change. Defaults to `false`.",
"type": "boolean"
},
"changelog-type": {
"description": "The type of changelog to use. Defaults to `default`.",
"type": "string",
Expand Down Expand Up @@ -496,6 +500,7 @@
"snapshot-label": true,
"initial-version": true,
"exclude-paths": true,
"component-no-space": false
"component-no-space": false,
"tag-head-sha": false
}
}
6 changes: 6 additions & 0 deletions src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ function taggingOptions(yargs: yargs.Argv): yargs.Argv {
'release-please automatically adds ` ` (space) in front of parsed ${component}. Should this be disabled?',
type: 'boolean',
default: false,
})
.option('tag-head-sha', {
describe:
'tag the head of the branch with the updated code - not the squashed commit',
type: 'boolean',
default: false,
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export interface ReleaserConfig {
skipSnapshot?: boolean;
// Manifest only
excludePaths?: string[];

tagHeadSha?: boolean;
}

export interface CandidateReleasePullRequest {
Expand Down Expand Up @@ -189,6 +191,7 @@ interface ReleaserConfigJson {
'skip-snapshot'?: boolean; // Java-only
'initial-version'?: string;
'exclude-paths'?: string[]; // manifest-only
'tag-head-sha'?: boolean;
}

export interface ManifestOptions {
Expand Down Expand Up @@ -1403,6 +1406,7 @@ function extractReleaserConfig(
skipSnapshot: config['skip-snapshot'],
initialVersion: config['initial-version'],
excludePaths: config['exclude-paths'],
tagHeadSha: config['tag-head-sha'],
};
}

Expand Down
12 changes: 11 additions & 1 deletion src/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface BaseStrategyOptions {
logger?: Logger;
initialVersion?: string;
extraLabels?: string[];
tagHeadSha?: boolean;
}

/**
Expand Down Expand Up @@ -114,6 +115,7 @@ export abstract class BaseStrategy implements Strategy {
readonly componentNoSpace?: boolean;
readonly extraFiles: ExtraFile[];
readonly extraLabels: string[];
readonly tagHeadSha?: boolean;

readonly changelogNotes: ChangelogNotes;

Expand Down Expand Up @@ -149,6 +151,7 @@ export abstract class BaseStrategy implements Strategy {
this.extraFiles = options.extraFiles || [];
this.initialVersion = options.initialVersion;
this.extraLabels = options.extraLabels || [];
this.tagHeadSha = options.tagHeadSha;
}

/**
Expand Down Expand Up @@ -691,11 +694,18 @@ export abstract class BaseStrategy implements Strategy {
component && this.includeComponentInTag
? `${component}: v${version.toString()}`
: `v${version.toString()}`;
const githubSourceSha = process.env.GITHUB_SOURCE_SHA;
var newSha = ''
if (this.tagHeadSha && githubSourceSha !== undefined) {
newSha = githubSourceSha
} else {
newSha = mergedPullRequest.sha
}
return {
name: releaseName,
tag,
notes: notes || '',
sha: mergedPullRequest.sha,
sha: newSha,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/updaters/release-please-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function releaserConfigToJsonConfig(
'extra-files': config.extraFiles,
'version-file': config.versionFile,
'snapshot-label': config.snapshotLabels?.join(','), // Java-only
'tag-head-sha': config.tagHeadSha,
};
return jsonConfig;
}

0 comments on commit 777f68a

Please sign in to comment.