mirror of
https://github.com/goreleaser/goreleaser-action.git
synced 2026-05-22 10:11:54 +00:00
Resolves the GoReleaser version from a file. Currently supports the
asdf/mise `.tool-versions` format; resolved value takes precedence
over the `version` input.
# .tool-versions
goreleaser 2.13.0
- uses: goreleaser/goreleaser-action@v7
with:
version-file: .tool-versions
args: release --clean
Path is resolved relative to `workdir` unless absolute. Bare semvers
are auto-prefixed with `v`; constraint expressions and `latest` are
returned as-is. Multiple fallback versions per asdf convention are
accepted but only the first is used.
Refs #541
Closes #542
Co-authored-by: Anthony Couvreur <22034450+acouvreur@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
77 lines
2.2 KiB
TypeScript
77 lines
2.2 KiB
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import yargs from 'yargs';
|
|
import type {Arguments} from 'yargs';
|
|
import * as context from './context';
|
|
import * as goreleaser from './goreleaser';
|
|
import {getRequestedVersion} from './version';
|
|
import * as core from '@actions/core';
|
|
import * as exec from '@actions/exec';
|
|
|
|
async function run(): Promise<void> {
|
|
try {
|
|
const inputs: context.Inputs = await context.getInputs();
|
|
const version = getRequestedVersion(inputs);
|
|
const bin = await goreleaser.install(inputs.distribution, version);
|
|
core.info(`GoReleaser ${version} installed successfully`);
|
|
|
|
if (inputs.installOnly) {
|
|
const goreleaserDir = path.dirname(bin);
|
|
core.addPath(goreleaserDir);
|
|
core.debug(`Added ${goreleaserDir} to PATH`);
|
|
return;
|
|
} else if (!inputs.args) {
|
|
core.setFailed('args input required');
|
|
return;
|
|
}
|
|
|
|
if (inputs.workdir && inputs.workdir !== '.') {
|
|
core.info(`Using ${inputs.workdir} as working directory`);
|
|
process.chdir(inputs.workdir);
|
|
}
|
|
|
|
let yamlfile: string | unknown;
|
|
const argv: Arguments<{config?: string}> = yargs(inputs.args).parseSync() as Arguments<{
|
|
config?: string;
|
|
}>;
|
|
if (argv.config) {
|
|
yamlfile = argv.config;
|
|
} else {
|
|
[
|
|
'.config/goreleaser.yaml',
|
|
'.config/goreleaser.yml',
|
|
'.goreleaser.yaml',
|
|
'.goreleaser.yml',
|
|
'goreleaser.yaml',
|
|
'goreleaser.yml'
|
|
].forEach(f => {
|
|
if (fs.existsSync(f)) {
|
|
yamlfile = f;
|
|
}
|
|
});
|
|
}
|
|
|
|
await exec.exec(`${bin} ${inputs.args}`);
|
|
|
|
if (typeof yamlfile === 'string') {
|
|
const artifacts = await goreleaser.getArtifacts(await goreleaser.getDistPath(yamlfile));
|
|
if (artifacts) {
|
|
await core.group(`Artifacts output`, async () => {
|
|
core.info(artifacts);
|
|
core.setOutput('artifacts', artifacts);
|
|
});
|
|
}
|
|
const metadata = await goreleaser.getMetadata(await goreleaser.getDistPath(yamlfile));
|
|
if (metadata) {
|
|
await core.group(`Metadata output`, async () => {
|
|
core.info(metadata);
|
|
core.setOutput('metadata', metadata);
|
|
});
|
|
}
|
|
}
|
|
} catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
}
|
|
|
|
run();
|