Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add artifacts and metadata outputs #327

Merged
merged 1 commit into from Feb 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -22,6 +22,7 @@ ___
* [Install Only](#install-only)
* [Customizing](#customizing)
* [inputs](#inputs)
* [outputs](#outputs)
* [environment variables](#environment-variables)
* [Limitation](#limitation)
* [Development](#development)
Expand Down Expand Up @@ -50,8 +51,6 @@ jobs:
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand Down Expand Up @@ -179,6 +178,15 @@ Following inputs can be used as `step.with` keys

> **¹** Can be a fixed version like `v0.117.0` or a max satisfying semver one like `~> 0.132`. In this case this will return `v0.132.1`.
### outputs

Following outputs are available

| Name | Type | Description |
|-------------------|---------|---------------------------------------|
| `artifacts` | JSON | Build result artifacts |
| `metadata` | JSON | Build result metadata |

### environment variables

Following environment variables can be used as `step.env` keys
Expand Down
31 changes: 31 additions & 0 deletions __tests__/context.test.ts
@@ -0,0 +1,31 @@
import * as os from 'os';
import * as context from '../src/context';

describe('setOutput', () => {
beforeEach(() => {
process.stdout.write = jest.fn();
});

it('setOutput produces the correct command', () => {
context.setOutput('some output', 'some value');
assertWriteCalls([`::set-output name=some output::some value${os.EOL}`]);
});

it('setOutput handles bools', () => {
context.setOutput('some output', false);
assertWriteCalls([`::set-output name=some output::false${os.EOL}`]);
});

it('setOutput handles numbers', () => {
context.setOutput('some output', 1.01);
assertWriteCalls([`::set-output name=some output::1.01${os.EOL}`]);
});
});

// Assert that process.stdout.write calls called only with the given arguments.
function assertWriteCalls(calls: string[]): void {
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
for (let i = 0; i < calls.length; i++) {
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
}
}
6 changes: 6 additions & 0 deletions action.yml
Expand Up @@ -27,6 +27,12 @@ inputs:
default: 'false'
required: false

outputs:
artifacts:
description: 'Build result artifacts'
metadata:
description: 'Build result metadata'

runs:
using: 'node12'
main: 'dist/index.js'