Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .craft.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
minVersion: '2.14.0'
changelogPolicy: auto
changelog: auto
preReleaseCommand: >-
node -p "
const {execSync} = require('child_process');
Expand Down
9 changes: 8 additions & 1 deletion src/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import {
isBumpType,
type BumpType,
} from '../utils/autoVersion';
import { isDryRun, promptConfirmation } from '../utils/helpers';
import {
isDryRun,
promptConfirmation,
setGitHubActionsOutput,
} from '../utils/helpers';
import { formatJson } from '../utils/strings';
import { spawnProcess } from '../utils/system';
import { isValidVersion } from '../utils/version';
Expand Down Expand Up @@ -549,6 +553,9 @@ export async function prepareMain(argv: PrepareOptions): Promise<any> {
logger.info(`Version bump: ${currentVersion} -> ${newVersion} (${bumpType} bump)`);
}

// Emit resolved version for GitHub Actions
setGitHubActionsOutput('version', newVersion);

logger.info(`Releasing version ${newVersion} from ${rev}`);
if (!argv.rev && rev !== defaultBranch) {
logger.warn("You're not on your default branch, so I have to ask...");
Expand Down
13 changes: 13 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { appendFileSync } from 'fs';

import prompts from 'prompts';
import { logger, LogLevel, setLevel } from '../logger';

Expand Down Expand Up @@ -59,3 +61,14 @@ export async function promptConfirmation(): Promise<void> {
export function hasInput(): boolean {
return !GLOBAL_FLAGS['no-input'];
}

/**
* Sets a GitHub Actions output variable.
* No-op when not running in GitHub Actions.
*/
export function setGitHubActionsOutput(name: string, value: string): void {
const outputFile = process.env.GITHUB_OUTPUT;
if (outputFile) {
appendFileSync(outputFile, `${name}=${value}\n`);
}
}
Loading