Skip to content

Commit

Permalink
fix: artifacts
Browse files Browse the repository at this point in the history
sethyates committed Aug 28, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b01615b commit 58c8f05
Showing 9 changed files with 12,710 additions and 6,458 deletions.
8 changes: 8 additions & 0 deletions __tests__/util.test.ts
Original file line number Diff line number Diff line change
@@ -114,6 +114,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: undefined,
@@ -139,6 +140,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: undefined,
@@ -163,6 +165,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: undefined,
@@ -188,6 +191,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: undefined,
@@ -216,6 +220,7 @@ describe('util', () => {
github_repository: '',
github_token: 'input-token',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: false,
@@ -242,6 +247,7 @@ describe('util', () => {
github_repository: '',
github_token: 'input-token',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: false,
@@ -267,6 +273,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: false,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: false,
@@ -291,6 +298,7 @@ describe('util', () => {
github_repository: '',
github_token: '',
input_append_body: true,
input_artifacts: [],
input_body: undefined,
input_body_path: undefined,
input_draft: undefined,
53 changes: 28 additions & 25 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
name: "create-release"
description: "Github Action for creating Github Releases"
author: "Conventional Actions"
name: 'create-release'
description: 'Github Action for creating Github Releases'
author: 'Conventional Actions'
inputs:
body:
description: "Noteworthy description of changes in release"
description: 'Noteworthy description of changes in release'
required: false
body_path:
description: "Path to load noteworthy description of changes in release from"
description: 'Path to load noteworthy description of changes in release from'
required: false
name:
description: "Gives the release a custom name. Defaults to tag name"
description: 'Gives the release a custom name. Defaults to tag name'
required: false
tag_name:
description: "Gives a tag name. Defaults to github.ref"
description: 'Gives a tag name. Defaults to github.ref'
required: false
default: ${{ github.ref }}
draft:
description: "Creates a draft release. Defaults to false"
description: 'Creates a draft release. Defaults to false'
required: false
default: 'false'
prerelease:
description: "Identify the release as a prerelease. Defaults to false"
description: 'Identify the release as a prerelease. Defaults to false'
required: false
default: 'false'
files:
description: "Newline-delimited list of path globs for asset files to upload"
description: 'Newline-delimited list of path globs for asset files to upload'
required: false
artifacts:
description: 'Newline-delimited list of artifact globs to upload'
required: false
fail_on_unmatched_files:
description: "Fails if any of the `files` globs match nothing. Defaults to false"
description: 'Fails if any of the `files` globs match nothing. Defaults to false'
required: false
default: 'false'
repository:
description: "Repository to make releases against, in <owner>/<repo> format"
description: 'Repository to make releases against, in <owner>/<repo> format'
required: false
token:
description: "Authorized secret GitHub Personal Access Token. Defaults to github.token"
description: 'Authorized secret GitHub Personal Access Token. Defaults to github.token'
required: false
default: ${{ github.token }}
target_commitish:
description: "Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA."
description: 'Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.'
required: false
discussion_category_name:
description: "If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. If there is already a discussion linked to the release, this parameter is ignored."
description: 'If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. If there is already a discussion linked to the release, this parameter is ignored.'
required: false
generate_release_notes:
description: "Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes."
description: 'Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes.'
required: false
default: 'true'
append_body:
description: "Append to existing body instead of overwriting it. Default is false."
description: 'Append to existing body instead of overwriting it. Default is false.'
required: false
default: 'false'
outputs:
url:
description: "URL to the Release HTML Page"
description: 'URL to the Release HTML Page'
id:
description: "Release ID"
description: 'Release ID'
upload_url:
description: "URL for uploading assets to the release"
description: 'URL for uploading assets to the release'
assets:
description: "JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/reference/repos#upload-a-release-asset--code-samples) (minus the `uploader` field)"
description: 'JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/reference/repos#upload-a-release-asset--code-samples) (minus the `uploader` field)'
runs:
using: "node16"
main: "dist/index.js"
using: 'node16'
main: 'dist/index.js'
branding:
color: "purple"
icon: "package"
color: 'purple'
icon: 'package'
18,797 changes: 12,479 additions & 6,318 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

178 changes: 67 additions & 111 deletions package-lock.json
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
"author": "Conventional Actions",
"license": "MIT",
"dependencies": {
"@actions/artifact": "^1.1.0",
"@actions/core": "^1.9.1",
"@actions/github": "^5.0.3",
"@actions/glob": "^0.3.0",
21 changes: 18 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import {paths, parseConfig, isTag, unmatchedPatterns, uploadUrl} from './util'
import {release, upload} from './github'
import * as github from '@actions/github'
import * as core from '@actions/core'
import * as artifact from '@actions/artifact'

async function run(): Promise<void> {
try {
@@ -51,12 +52,26 @@ async function run(): Promise<void> {
const rel = await release(config, gh)
core.debug(`rel = ${JSON.stringify(rel)}`)

if (config.input_files && config.input_files.length > 0) {
const files = paths(config.input_files)
let input_files = config.input_files || []

if (config.input_artifacts && config.input_artifacts.length > 0) {
const artifacts = paths(config.input_artifacts)
core.debug(`artifacts = ${artifacts}`)

const artifactPaths = await artifact.create().downloadAllArtifacts()
core.debug(`artifactPaths = ${artifactPaths}`)

for (const artifactPath of artifactPaths) {
input_files = input_files.concat(artifactPath.downloadPath)
}
}

if (input_files.length > 0) {
const files = paths(input_files)
core.debug(`files = ${files}`)

if (files.length === 0) {
core.warning(`${config.input_files} not include valid file.`)
core.warning(`${input_files} not include valid file.`)
}

const currentAssets = rel.assets
2 changes: 2 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ export interface Config {
input_body?: string
input_body_path?: string
input_files?: string[]
input_artifacts?: string[]
input_draft?: boolean
input_prerelease?: boolean
input_fail_on_unmatched_files?: boolean
@@ -59,6 +60,7 @@ export const parseConfig = (env: Env): Config => {
input_body: env.INPUT_BODY,
input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ''),
input_artifacts: parseInputFiles(env.INPUT_ARTIFACTS || ''),
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === 'true' : undefined,
input_prerelease: env.INPUT_PRERELEASE
? env.INPUT_PRERELEASE === 'true'

0 comments on commit 58c8f05

Please sign in to comment.