Merge branch 'alerque-default-token'

This commit is contained in:
softprops 2021-07-25 20:11:43 -04:00
commit 6aeb2b7009
5 changed files with 63 additions and 62 deletions

View file

@ -1,4 +1,3 @@
<div align="center">
📦 :octocat:
</div>
@ -20,7 +19,6 @@
</a>
</div>
<br />
## 🤸 Usage
@ -47,8 +45,6 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
You can also use push config tag filter
@ -59,7 +55,7 @@ name: Main
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"
jobs:
build:
@ -69,8 +65,6 @@ jobs:
uses: actions/checkout@v2
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### ⬆️ Uploading release assets
@ -104,8 +98,6 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
files: Release.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Below is an example of uploading more than one asset with a GitHub release
@ -132,8 +124,6 @@ jobs:
files: |
Release.txt
LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
> **⚠️ Note:** Notice the `|` in the yaml syntax above ☝️. That let's you effectively declare a multi-line yaml string. You can learn more about multi-line yaml syntax [here](https://yaml-multiline.info)
@ -163,7 +153,6 @@ jobs:
with:
body_path: ${{ github.workflow }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
```
@ -173,17 +162,20 @@ jobs:
The following are optional as `step.with` keys
| Name | Type | Description |
| Name | Type | Description |
|---------------------------|---------|-----------------------------------------------------------------------------------------------------|
| `body` | String | Text communicating notable changes in this release |
| `body_path` | String | Path to load text communicating notable changes in this release |
| `draft` | Boolean | Indicator of whether or not this release is a draft |
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
| `body` | String | Text communicating notable changes in this release |
| `body_path` | String | Path to load text communicating notable changes in this release |
| `draft` | Boolean | Indicator of whether or not this release is a draft |
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
| `token` | String | Secret GitHub Personal Access Token. Defaults to `${{ github.token }}` |
💡 When providing a `body` and `body_path` at the same time, `body_path` will be
attempted first, then falling back on `body` if the path can not be read from.
@ -196,22 +188,20 @@ release will retain its original info.
The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from this action
| Name | Type | Description |
|-------------|---------|-----------------------------------------------------------------|
| `url` | String | Github.com URL for the release |
| `id` | String | Release ID |
| `upload_url`| String | URL for uploading assets to the release |
| Name | Type | Description |
| ------------ | ------ | --------------------------------------- |
| `url` | String | Github.com URL for the release |
| `id` | String | Release ID |
| `upload_url` | String | URL for uploading assets to the release |
#### environment variables
The following are *required* as `step.env` keys
| Name | Description |
|----------------|--------------------------------------|
| `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets`|
| `GITHUB_REPOSITORY` | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository|
The following `step.env` keys are allowed as a fallback but deprecated in favor of using inputs.
| Name | Description |
| ------------------- | ------------------------------------------------------------------------------------------ |
| `GITHUB_TOKEN` | GITHUB_TOKEN as provided by `secrets` |
| `GITHUB_REPOSITORY` | Name of a target repository in `<owner>/<repo>` format. defaults to the current repository |
> **⚠️ Note:** This action was previously implemented as a Docker container, limiting its use to GitHub Actions Linux virtual environments only. With recent releases, we now support cross platform usage. You'll need to remove the `docker://` prefix in these versions

View file

@ -1,50 +1,60 @@
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: 'GH Release'
description: 'Github Action for creating Github Releases'
author: 'softprops'
name: "GH Release"
description: "Github Action for creating Github Releases"
author: "softprops"
inputs:
body:
description: 'Note-worthy description of changes in release'
description: "Note-worthy description of changes in release"
required: false
body_path:
description: 'Path to load note-worthy description of changes in release from'
description: "Path to load note-worthy 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.GITHUB_REF'
description: "Gives a tag name. Defaults to github.GITHUB_REF"
required: false
draft:
description: 'Creates a draft release. Defaults to false'
description: "Creates a draft release. Defaults to false"
required: false
prerelease:
description: 'Identify the release as a prerelease. Defaults to false'
description: "Identify the release as a prerelease. Defaults to false"
required: 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
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
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"
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."
required: false
target_commitish:
description: 'Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.'
required: false
target_commitish:
description: 'Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA.'
required: false
env:
'GITHUB_TOKEN': 'As provided by Github Actions'
"GITHUB_TOKEN": "As provided by Github Actions"
outputs:
url:
description: 'URL to the Release HTML Page'
id:
description: 'Release ID'
upload_url:
description: 'URL for uploading assets to the release'
description: "URL for uploading assets to the release"
runs:
using: 'node12'
main: 'dist/index.js'
using: "node12"
main: "dist/index.js"
branding:
color: 'green'
icon: 'package'
color: "green"
icon: "package"

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -116,7 +116,7 @@ export const asset = (path: string): ReleaseAsset => {
name: basename(path),
mime: mimeOrDefault(path),
size: lstatSync(path).size,
file: readFileSync(path)
file: readFileSync(path),
};
};
@ -135,10 +135,10 @@ export const upload = async (
url,
headers: {
"content-length": size,
"content-type": mime
"content-type": mime,
},
name,
file
file,
});
};
@ -164,9 +164,9 @@ export const release = async (
if (config.input_draft) {
for await (const response of releaser.allReleases({
owner,
repo
repo,
})) {
let release = response.data.find(release => release.tag_name === tag);
let release = response.data.find((release) => release.tag_name === tag);
if (release) {
return release;
}
@ -175,7 +175,7 @@ export const release = async (
let existingRelease = await releaser.getReleaseByTag({
owner,
repo,
tag
tag,
});
const release_id = existingRelease.data.id;
@ -219,7 +219,7 @@ export const release = async (
name,
body,
draft,
prerelease
prerelease,
});
return release.data;
} catch (error) {
@ -246,7 +246,7 @@ export const release = async (
body,
draft,
prerelease,
target_commitish
target_commitish,
});
return release.data;
} catch (error) {

View file

@ -1,3 +1,4 @@
import { getInput } from "@actions/core";
import * as glob from "glob";
import { lstatSync, readFileSync } from "fs";
@ -41,7 +42,7 @@ export const parseInputFiles = (files: string): string[] => {
export const parseConfig = (env: Env): Config => {
return {
github_token: env.GITHUB_TOKEN || "",
github_token: getInput("token") || env.GITHUB_TOKEN || "",
github_ref: env.GITHUB_REF || "",
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
input_name: env.INPUT_NAME,