Allow to run GoReleaser from a subdirectory (#45)

This commit is contained in:
Boaz Yaniv 2019-12-02 18:54:32 +09:00 committed by CrazyMax
parent 6ec955d9f0
commit 16077aaddc
4 changed files with 20 additions and 5 deletions

View File

@ -54,10 +54,11 @@ jobs:
Following inputs can be used as `step.with` keys Following inputs can be used as `step.with` keys
| Name | Type | Default | Description | | Name | Type | Default | Description |
|---------------|---------|-----------|------------------------------------------| |---------------|---------|-----------|-------------------------------------------|
| `version` | String | `latest` | GoReleaser version. Example: `v0.117.0` | | `version` | String | `latest` | GoReleaser version. Example: `v0.117.0` |
| `args` | String | | Arguments to pass to GoReleaser | | `args` | String | | Arguments to pass to GoReleaser |
| `key` | String | | Private key to import | | `key` | String | | Private key to import |
| `workdir` | String | `.` | Working directory (below repository root) |
### Signing ### Signing

View File

@ -14,6 +14,9 @@ inputs:
description: 'Arguments to pass to GoReleaser' description: 'Arguments to pass to GoReleaser'
key: key:
description: 'Private key to import' description: 'Private key to import'
workdir:
description: 'Working directory (below repository root)'
default: '.'
runs: runs:
using: 'node12' using: 'node12'

View File

@ -26,7 +26,12 @@ function run(silent) {
const version = core.getInput('version') || 'latest'; const version = core.getInput('version') || 'latest';
const args = core.getInput('args'); const args = core.getInput('args');
const key = core.getInput('key'); const key = core.getInput('key');
const workdir = core.getInput('workdir') || '.';
const goreleaser = yield installer.getGoReleaser(version); const goreleaser = yield installer.getGoReleaser(version);
if (workdir && workdir !== '.') {
console.log(`📂 Using ${workdir} as working directory...`);
process.chdir(workdir);
}
let snapshot = ''; let snapshot = '';
if (!process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) { if (!process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) {
console.log(`⚠️ No tag found. Snapshot forced`); console.log(`⚠️ No tag found. Snapshot forced`);

View File

@ -8,8 +8,14 @@ export async function run(silent?: boolean) {
const version = core.getInput('version') || 'latest'; const version = core.getInput('version') || 'latest';
const args = core.getInput('args'); const args = core.getInput('args');
const key = core.getInput('key'); const key = core.getInput('key');
const workdir = core.getInput('workdir') || '.';
const goreleaser = await installer.getGoReleaser(version); const goreleaser = await installer.getGoReleaser(version);
if (workdir && workdir !== '.') {
console.log(`📂 Using ${workdir} as working directory...`)
process.chdir(workdir);
}
let snapshot = ''; let snapshot = '';
if (!process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) { if (!process.env.GITHUB_REF || !process.env.GITHUB_REF.startsWith('refs/tags/')) {
console.log(`⚠️ No tag found. Snapshot forced`); console.log(`⚠️ No tag found. Snapshot forced`);