Merge branch 'alerque-default-token'
This commit is contained in:
commit
6aeb2b7009
58
README.md
58
README.md
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
📦 :octocat:
|
📦 :octocat:
|
||||||
</div>
|
</div>
|
||||||
@ -20,7 +19,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## 🤸 Usage
|
## 🤸 Usage
|
||||||
@ -47,8 +45,6 @@ jobs:
|
|||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also use push config tag filter
|
You can also use push config tag filter
|
||||||
@ -59,7 +55,7 @@ name: Main
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- "v*.*.*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -69,8 +65,6 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### ⬆️ Uploading release assets
|
### ⬆️ Uploading release assets
|
||||||
@ -104,8 +98,6 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
files: Release.txt
|
files: Release.txt
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Below is an example of uploading more than one asset with a GitHub release
|
Below is an example of uploading more than one asset with a GitHub release
|
||||||
@ -132,8 +124,6 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
Release.txt
|
Release.txt
|
||||||
LICENSE
|
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)
|
> **⚠️ 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:
|
with:
|
||||||
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
|
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -173,17 +162,20 @@ jobs:
|
|||||||
|
|
||||||
The following are optional as `step.with` keys
|
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 |
|
| `body` | String | Text communicating notable changes in this release |
|
||||||
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
| `body_path` | String | Path to load text communicating notable changes in this release |
|
||||||
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
|
| `draft` | Boolean | Indicator of whether or not this release is a draft |
|
||||||
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
|
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
|
||||||
| `name` | String | Name of the release. defaults to tag name |
|
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
|
||||||
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
|
| `name` | String | Name of the release. defaults to tag name |
|
||||||
| `fail_on_unmatched_files` | Boolean | Indicator of whether to fail if any of the `files` globs match nothing |
|
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
|
||||||
| `target_commitish` | String | Commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. |
|
| `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
|
💡 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.
|
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
|
The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from this action
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
|-------------|---------|-----------------------------------------------------------------|
|
| ------------ | ------ | --------------------------------------- |
|
||||||
| `url` | String | Github.com URL for the release |
|
| `url` | String | Github.com URL for the release |
|
||||||
| `id` | String | Release ID |
|
| `id` | String | Release ID |
|
||||||
| `upload_url`| String | URL for uploading assets to the release |
|
| `upload_url` | String | URL for uploading assets to the release |
|
||||||
|
|
||||||
|
|
||||||
#### environment variables
|
#### environment variables
|
||||||
|
|
||||||
The following are *required* as `step.env` keys
|
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|
|
|
||||||
|
|
||||||
|
| 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
|
> **⚠️ 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
|
||||||
|
|
||||||
|
46
action.yml
46
action.yml
@ -1,50 +1,60 @@
|
|||||||
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
|
||||||
name: 'GH Release'
|
name: "GH Release"
|
||||||
description: 'Github Action for creating Github Releases'
|
description: "Github Action for creating Github Releases"
|
||||||
author: 'softprops'
|
author: "softprops"
|
||||||
inputs:
|
inputs:
|
||||||
body:
|
body:
|
||||||
description: 'Note-worthy description of changes in release'
|
description: "Note-worthy description of changes in release"
|
||||||
required: false
|
required: false
|
||||||
body_path:
|
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
|
required: false
|
||||||
name:
|
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
|
required: false
|
||||||
tag_name:
|
tag_name:
|
||||||
description: 'Gives a tag name. Defaults to github.GITHUB_REF'
|
description: "Gives a tag name. Defaults to github.GITHUB_REF"
|
||||||
required: false
|
required: false
|
||||||
draft:
|
draft:
|
||||||
description: 'Creates a draft release. Defaults to false'
|
description: "Creates a draft release. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
prerelease:
|
prerelease:
|
||||||
description: 'Identify the release as a prerelease. Defaults to false'
|
description: "Identify the release as a prerelease. Defaults to false"
|
||||||
required: false
|
required: false
|
||||||
files:
|
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
|
required: false
|
||||||
fail_on_unmatched_files:
|
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
|
required: false
|
||||||
repository:
|
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
|
required: false
|
||||||
target_commitish:
|
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
|
required: false
|
||||||
env:
|
env:
|
||||||
'GITHUB_TOKEN': 'As provided by Github Actions'
|
"GITHUB_TOKEN": "As provided by Github Actions"
|
||||||
outputs:
|
outputs:
|
||||||
url:
|
url:
|
||||||
description: 'URL to the Release HTML Page'
|
description: 'URL to the Release HTML Page'
|
||||||
id:
|
id:
|
||||||
description: 'Release ID'
|
description: 'Release ID'
|
||||||
upload_url:
|
upload_url:
|
||||||
description: 'URL for uploading assets to the release'
|
description: "URL for uploading assets to the release"
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: "node12"
|
||||||
main: 'dist/index.js'
|
main: "dist/index.js"
|
||||||
branding:
|
branding:
|
||||||
color: 'green'
|
color: "green"
|
||||||
icon: 'package'
|
icon: "package"
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -116,7 +116,7 @@ export const asset = (path: string): ReleaseAsset => {
|
|||||||
name: basename(path),
|
name: basename(path),
|
||||||
mime: mimeOrDefault(path),
|
mime: mimeOrDefault(path),
|
||||||
size: lstatSync(path).size,
|
size: lstatSync(path).size,
|
||||||
file: readFileSync(path)
|
file: readFileSync(path),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,10 +135,10 @@ export const upload = async (
|
|||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
"content-length": size,
|
"content-length": size,
|
||||||
"content-type": mime
|
"content-type": mime,
|
||||||
},
|
},
|
||||||
name,
|
name,
|
||||||
file
|
file,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -164,9 +164,9 @@ export const release = async (
|
|||||||
if (config.input_draft) {
|
if (config.input_draft) {
|
||||||
for await (const response of releaser.allReleases({
|
for await (const response of releaser.allReleases({
|
||||||
owner,
|
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) {
|
if (release) {
|
||||||
return release;
|
return release;
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ export const release = async (
|
|||||||
let existingRelease = await releaser.getReleaseByTag({
|
let existingRelease = await releaser.getReleaseByTag({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
tag
|
tag,
|
||||||
});
|
});
|
||||||
|
|
||||||
const release_id = existingRelease.data.id;
|
const release_id = existingRelease.data.id;
|
||||||
@ -219,7 +219,7 @@ export const release = async (
|
|||||||
name,
|
name,
|
||||||
body,
|
body,
|
||||||
draft,
|
draft,
|
||||||
prerelease
|
prerelease,
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -246,7 +246,7 @@ export const release = async (
|
|||||||
body,
|
body,
|
||||||
draft,
|
draft,
|
||||||
prerelease,
|
prerelease,
|
||||||
target_commitish
|
target_commitish,
|
||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { getInput } from "@actions/core";
|
||||||
import * as glob from "glob";
|
import * as glob from "glob";
|
||||||
import { lstatSync, readFileSync } from "fs";
|
import { lstatSync, readFileSync } from "fs";
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ export const parseInputFiles = (files: string): string[] => {
|
|||||||
|
|
||||||
export const parseConfig = (env: Env): Config => {
|
export const parseConfig = (env: Env): Config => {
|
||||||
return {
|
return {
|
||||||
github_token: env.GITHUB_TOKEN || "",
|
github_token: getInput("token") || env.GITHUB_TOKEN || "",
|
||||||
github_ref: env.GITHUB_REF || "",
|
github_ref: env.GITHUB_REF || "",
|
||||||
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
|
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
|
||||||
input_name: env.INPUT_NAME,
|
input_name: env.INPUT_NAME,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user