Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb0163a75b | |||
07c2133a09 | |||
f5d13571ca | |||
5e6fc64554 | |||
fdb5f68261 | |||
2b68b29aae | |||
6aeb2b7009 | |||
b323b1872a | |||
7fd0762403 | |||
f6cd293a1e | |||
350afcd40d | |||
7cf90a9adf | |||
51ef4d3b15 | |||
2e6aa9a7f0 | |||
12960c68c9 | |||
e314c6fe22 | |||
3973e5f15a | |||
cb6e676133 | |||
defeeb7d92 | |||
9f3b580ccc | |||
59b9126341 | |||
04c14f526b | |||
2934fce629 | |||
674bcd2d67 | |||
6f63b4506e | |||
36fae76a5c | |||
5eea929306 | |||
12d1ded340 | |||
766a84c1cf | |||
3c49988886 | |||
4204c40f52 | |||
f1168d714c | |||
ccb8d16f08 | |||
75dbd0cd0e | |||
ec9df7c385 | |||
03c4bc34bd | |||
0a4afc0be2 | |||
0a19cfc696 | |||
b1829982df | |||
688f58f697 | |||
3b4957b6fd | |||
05d11c9fe8 | |||
7e3b173db6 | |||
d5e4f508ae |
@ -1,3 +1,9 @@
|
||||
## 0.1.7
|
||||
|
||||
- allow creating draft releases without a tag [#95](https://github.com/softprops/action-gh-release/pull/95)
|
||||
- Set default token for simpler setup [#83](https://github.com/softprops/action-gh-release/pull/83)
|
||||
- fix regression with action yml [#126](https://github.com/softprops/action-gh-release/pull/126)
|
||||
|
||||
## 0.1.6
|
||||
|
||||
This is a release catch up have a hiatus. Future releases will happen more frequently
|
||||
|
42
README.md
42
README.md
@ -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)
|
||||
@ -156,14 +146,13 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Generate Changelog
|
||||
run: echo "# Good things have arrived" > ${{ github.workflow }}-CHANGELOG.txt
|
||||
run: echo "# Good things have arrived" > ${{ github.workspace }}-CHANGELOG.txt
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
body_path: ${{ github.workflow }}-CHANGELOG.txt
|
||||
body_path: ${{ github.workspace }}-CHANGELOG.txt
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
|
||||
```
|
||||
|
||||
@ -174,7 +163,7 @@ jobs:
|
||||
The following are optional as `step.with` keys
|
||||
|
||||
| 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 |
|
||||
@ -184,6 +173,7 @@ The following are optional as `step.with` keys
|
||||
| `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 +186,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
|
||||
|
||||
|
42
action.yml
42
action.yml
@ -1,50 +1,54 @@
|
||||
# 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.'
|
||||
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
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "action-gh-release",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"private": true,
|
||||
"description": "GitHub Action for creating GitHub Releases",
|
||||
"main": "lib/main.js",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { GitHub } from "@actions/github";
|
||||
import { Config, releaseBody } from "./util";
|
||||
import { Config, isTag, releaseBody } from "./util";
|
||||
import { lstatSync, readFileSync } from "fs";
|
||||
import { getType } from "mime";
|
||||
import { basename } from "path";
|
||||
@ -154,7 +154,10 @@ export const release = async (
|
||||
|
||||
const [owner, repo] = config.github_repository.split("/");
|
||||
const tag =
|
||||
config.input_tag_name || config.github_ref.replace("refs/tags/", "");
|
||||
config.input_tag_name ||
|
||||
(isTag(config.github_ref)
|
||||
? config.github_ref.replace("refs/tags/", "")
|
||||
: "");
|
||||
try {
|
||||
// you can't get a an existing draft by tag
|
||||
// so we must find one in the list of all releases
|
||||
|
14
src/main.ts
14
src/main.ts
@ -7,7 +7,11 @@ import { env } from "process";
|
||||
async function run() {
|
||||
try {
|
||||
const config = parseConfig(env);
|
||||
if (!config.input_tag_name && !isTag(config.github_ref)) {
|
||||
if (
|
||||
!config.input_tag_name &&
|
||||
!isTag(config.github_ref) &&
|
||||
!config.input_draft
|
||||
) {
|
||||
throw new Error(`⚠️ GitHub Releases requires a tag`);
|
||||
}
|
||||
if (config.input_files) {
|
||||
@ -49,8 +53,12 @@ async function run() {
|
||||
if (files.length == 0) {
|
||||
console.warn(`🤔 ${config.input_files} not include valid file.`);
|
||||
}
|
||||
files.forEach(async path => {
|
||||
await upload(gh, rel.upload_url, path);
|
||||
await Promise.all(
|
||||
files.map(async path => {
|
||||
await upload(gh, rel.upload_url, path);
|
||||
})
|
||||
).catch(error => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
console.log(`🎉 Release ready at ${rel.html_url}`);
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user