Skip to content

Commit

Permalink
feat: add artifacts and metadata outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Feb 27, 2022
1 parent 39419c3 commit 4b5a16a
Show file tree
Hide file tree
Showing 9 changed files with 9,793 additions and 1,749 deletions.
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -23,6 +23,7 @@ ___
* [Install Only](#install-only)
* [Customizing](#customizing)
* [inputs](#inputs)
* [outputs](#outputs)
* [environment variables](#environment-variables)
* [Limitation](#limitation)
* [Development](#development)
Expand Down Expand Up @@ -51,8 +52,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 @@ -180,6 +179,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'

0 comments on commit 4b5a16a

Please sign in to comment.