Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb2d03176f | |||
08d85b1534 | |||
a636f98a4d | |||
288696be39 | |||
6de5d7916c | |||
a485adba73 | |||
26f874e54a | |||
810bfa2cd5 | |||
019fc2114d | |||
a74c6b72af | |||
b909f761f0 | |||
e49d08fa32 | |||
f12ad255e1 | |||
7039a825a7 | |||
f9c2b6ca37 | |||
73738a6293 | |||
a500a35279 |
22
.github/release.yml
vendored
Normal file
22
.github/release.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
changelog:
|
||||||
|
exclude:
|
||||||
|
labels:
|
||||||
|
- ignore-for-release
|
||||||
|
- github-actions
|
||||||
|
authors:
|
||||||
|
- octocat
|
||||||
|
- renovate[bot]
|
||||||
|
categories:
|
||||||
|
- title: Breaking Changes 🛠
|
||||||
|
labels:
|
||||||
|
- breaking-change
|
||||||
|
- title: Exciting New Features 🎉
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
- feature
|
||||||
|
- title: Bug fixes 🐛
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
- title: Other Changes 🔄
|
||||||
|
labels:
|
||||||
|
- "*"
|
@ -1,3 +1,7 @@
|
|||||||
|
## 2.0.6
|
||||||
|
|
||||||
|
- maintenance release with updated dependencies
|
||||||
|
|
||||||
## 2.0.5
|
## 2.0.5
|
||||||
|
|
||||||
- Factor in file names with spaces when upserting files [#446](https://github.com/softprops/action-gh-release/pull/446) via [@MystiPanda](https://github.com/MystiPanda)
|
- Factor in file names with spaces when upserting files [#446](https://github.com/softprops/action-gh-release/pull/446) via [@MystiPanda](https://github.com/MystiPanda)
|
||||||
|
@ -75,6 +75,7 @@ GitHub release and all are optional.
|
|||||||
A common case for GitHub releases is to upload your binary after its been validated and packaged.
|
A common case for GitHub releases is to upload your binary after its been validated and packaged.
|
||||||
Use the `with.files` input to declare a newline-delimited list of glob expressions matching the files
|
Use the `with.files` input to declare a newline-delimited list of glob expressions matching the files
|
||||||
you wish to upload to GitHub releases. If you'd like you can just list the files by name directly.
|
you wish to upload to GitHub releases. If you'd like you can just list the files by name directly.
|
||||||
|
If a tag already has a GitHub release, the existing release will be updated with the release assets.
|
||||||
|
|
||||||
Below is an example of uploading a single asset named `Release.txt`
|
Below is an example of uploading a single asset named `Release.txt`
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ inputs:
|
|||||||
description: "Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Can be `true`, `false`, or `legacy`. Uses GitHub api default if not provided"
|
description: "Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Can be `true`, `false`, or `legacy`. Uses GitHub api default if not provided"
|
||||||
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"
|
||||||
|
6
dist/index.js
vendored
6
dist/index.js
vendored
File diff suppressed because one or more lines are too long
5617
package-lock.json
generated
5617
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "action-gh-release",
|
"name": "action-gh-release",
|
||||||
"version": "2.0.5",
|
"version": "2.0.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "GitHub Action for creating GitHub Releases",
|
"description": "GitHub Action for creating GitHub Releases",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/main.ts --minify",
|
"build": "ncc build src/main.ts --minify",
|
||||||
|
"build-debug": "ncc build src/main.ts --v8-cache --source-map",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"fmt": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
"fmt": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
||||||
"fmtcheck": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
"fmtcheck": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
||||||
@ -22,22 +23,22 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"@octokit/plugin-retry": "^4.0.3",
|
"@octokit/plugin-retry": "^7.1.1",
|
||||||
"@octokit/plugin-throttling": "^4.3.2",
|
"@octokit/plugin-throttling": "^9.3.0",
|
||||||
"glob": "^8.0.3",
|
"glob": "^10.4.2",
|
||||||
"mime": "^3.0.0"
|
"mime": "^3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/glob": "^8.0.0",
|
"@types/glob": "^8.1.0",
|
||||||
"@types/jest": "^29.2.3",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/mime": "^3.0.1",
|
"@types/mime": "^3.0.1",
|
||||||
"@types/node": "^18.11.9",
|
"@types/node": "^20.14.9",
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"jest": "^29.3.1",
|
"jest": "^29.3.1",
|
||||||
"jest-circus": "^29.3.1",
|
"jest-circus": "^29.3.1",
|
||||||
"prettier": "2.8.0",
|
"prettier": "2.8.0",
|
||||||
"ts-jest": "^29.0.3",
|
"ts-jest": "^29.2.2",
|
||||||
"typescript": "^4.9.3",
|
"typescript": "^5.5.3",
|
||||||
"typescript-formatter": "^7.2.2"
|
"typescript-formatter": "^7.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
178
src/github.ts
178
src/github.ts
@ -208,45 +208,63 @@ export const release = async (
|
|||||||
try {
|
try {
|
||||||
// you can't get a an existing draft by tag
|
// you can't get a an existing draft by tag
|
||||||
// so we must find one in the list of all releases
|
// so we must find one in the list of all releases
|
||||||
|
let _release: Release | undefined = undefined;
|
||||||
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);
|
_release = response.data.find((release) => release.tag_name === tag);
|
||||||
if (release) {
|
|
||||||
return release;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_release = (
|
||||||
|
await releaser.getReleaseByTag({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
tag,
|
||||||
|
})
|
||||||
|
).data;
|
||||||
|
}
|
||||||
|
if (_release === null || _release === undefined) {
|
||||||
|
return await createRelease(
|
||||||
|
tag,
|
||||||
|
config,
|
||||||
|
releaser,
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
discussion_category_name,
|
||||||
|
generate_release_notes,
|
||||||
|
maxRetries
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let existingRelease = await releaser.getReleaseByTag({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
tag,
|
|
||||||
});
|
|
||||||
|
|
||||||
const release_id = existingRelease.data.id;
|
let existingRelease: Release = _release!;
|
||||||
|
console.log(
|
||||||
|
`Found release ${existingRelease.name} (with id=${existingRelease.id})`
|
||||||
|
);
|
||||||
|
|
||||||
|
const release_id = existingRelease.id;
|
||||||
let target_commitish: string;
|
let target_commitish: string;
|
||||||
if (
|
if (
|
||||||
config.input_target_commitish &&
|
config.input_target_commitish &&
|
||||||
config.input_target_commitish !== existingRelease.data.target_commitish
|
config.input_target_commitish !== existingRelease.target_commitish
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`Updating commit from "${existingRelease.data.target_commitish}" to "${config.input_target_commitish}"`
|
`Updating commit from "${existingRelease.target_commitish}" to "${config.input_target_commitish}"`
|
||||||
);
|
);
|
||||||
target_commitish = config.input_target_commitish;
|
target_commitish = config.input_target_commitish;
|
||||||
} else {
|
} else {
|
||||||
target_commitish = existingRelease.data.target_commitish;
|
target_commitish = existingRelease.target_commitish;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tag_name = tag;
|
const tag_name = tag;
|
||||||
const name = config.input_name || existingRelease.data.name || tag;
|
const name = config.input_name || existingRelease.name || tag;
|
||||||
// revisit: support a new body-concat-strategy input for accumulating
|
// revisit: support a new body-concat-strategy input for accumulating
|
||||||
// body parts as a release gets updated. some users will likely want this while
|
// body parts as a release gets updated. some users will likely want this while
|
||||||
// others won't previously this was duplicating content for most which
|
// others won't previously this was duplicating content for most which
|
||||||
// no one wants
|
// no one wants
|
||||||
const workflowBody = releaseBody(config) || "";
|
const workflowBody = releaseBody(config) || "";
|
||||||
const existingReleaseBody = existingRelease.data.body || "";
|
const existingReleaseBody = existingRelease.body || "";
|
||||||
let body: string;
|
let body: string;
|
||||||
if (config.input_append_body && workflowBody && existingReleaseBody) {
|
if (config.input_append_body && workflowBody && existingReleaseBody) {
|
||||||
body = existingReleaseBody + "\n" + workflowBody;
|
body = existingReleaseBody + "\n" + workflowBody;
|
||||||
@ -257,11 +275,11 @@ export const release = async (
|
|||||||
const draft =
|
const draft =
|
||||||
config.input_draft !== undefined
|
config.input_draft !== undefined
|
||||||
? config.input_draft
|
? config.input_draft
|
||||||
: existingRelease.data.draft;
|
: existingRelease.draft;
|
||||||
const prerelease =
|
const prerelease =
|
||||||
config.input_prerelease !== undefined
|
config.input_prerelease !== undefined
|
||||||
? config.input_prerelease
|
? config.input_prerelease
|
||||||
: existingRelease.data.prerelease;
|
: existingRelease.prerelease;
|
||||||
|
|
||||||
const make_latest = config.input_make_latest;
|
const make_latest = config.input_make_latest;
|
||||||
|
|
||||||
@ -288,58 +306,80 @@ export const release = async (
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tag_name = tag;
|
return await createRelease(
|
||||||
const name = config.input_name || tag;
|
tag,
|
||||||
const body = releaseBody(config);
|
config,
|
||||||
const draft = config.input_draft;
|
releaser,
|
||||||
const prerelease = config.input_prerelease;
|
owner,
|
||||||
const target_commitish = config.input_target_commitish;
|
repo,
|
||||||
const make_latest = config.input_make_latest;
|
discussion_category_name,
|
||||||
let commitMessage: string = "";
|
generate_release_notes,
|
||||||
if (target_commitish) {
|
maxRetries
|
||||||
commitMessage = ` using commit "${target_commitish}"`;
|
|
||||||
}
|
|
||||||
console.log(
|
|
||||||
`👩🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`
|
|
||||||
);
|
);
|
||||||
try {
|
|
||||||
let release = await releaser.createRelease({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
tag_name,
|
|
||||||
name,
|
|
||||||
body,
|
|
||||||
draft,
|
|
||||||
prerelease,
|
|
||||||
target_commitish,
|
|
||||||
discussion_category_name,
|
|
||||||
generate_release_notes,
|
|
||||||
make_latest,
|
|
||||||
});
|
|
||||||
return release.data;
|
|
||||||
} catch (error) {
|
|
||||||
// presume a race with competing matrix runs
|
|
||||||
console.log(`⚠️ GitHub release failed with status: ${error.status}`);
|
|
||||||
console.log(`${JSON.stringify(error.response.data)}`);
|
|
||||||
|
|
||||||
switch (error.status) {
|
|
||||||
case 403:
|
|
||||||
console.log(
|
|
||||||
"Skip retry — your GitHub token/PAT does not have the required permission to create a release"
|
|
||||||
);
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
case 404:
|
|
||||||
console.log("Skip retry - discussion category mismatch");
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
case 422:
|
|
||||||
console.log("Skip retry - validation failed");
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`retrying... (${maxRetries - 1} retries remaining)`);
|
|
||||||
return release(config, releaser, maxRetries - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function createRelease(
|
||||||
|
tag: string,
|
||||||
|
config: Config,
|
||||||
|
releaser: Releaser,
|
||||||
|
owner: string,
|
||||||
|
repo: string,
|
||||||
|
discussion_category_name: string | undefined,
|
||||||
|
generate_release_notes: boolean | undefined,
|
||||||
|
maxRetries: number
|
||||||
|
) {
|
||||||
|
const tag_name = tag;
|
||||||
|
const name = config.input_name || tag;
|
||||||
|
const body = releaseBody(config);
|
||||||
|
const draft = config.input_draft;
|
||||||
|
const prerelease = config.input_prerelease;
|
||||||
|
const target_commitish = config.input_target_commitish;
|
||||||
|
const make_latest = config.input_make_latest;
|
||||||
|
let commitMessage: string = "";
|
||||||
|
if (target_commitish) {
|
||||||
|
commitMessage = ` using commit "${target_commitish}"`;
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`👩🏭 Creating new GitHub release for tag ${tag_name}${commitMessage}...`
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
let release = await releaser.createRelease({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
tag_name,
|
||||||
|
name,
|
||||||
|
body,
|
||||||
|
draft,
|
||||||
|
prerelease,
|
||||||
|
target_commitish,
|
||||||
|
discussion_category_name,
|
||||||
|
generate_release_notes,
|
||||||
|
make_latest,
|
||||||
|
});
|
||||||
|
return release.data;
|
||||||
|
} catch (error) {
|
||||||
|
// presume a race with competing matrix runs
|
||||||
|
console.log(`⚠️ GitHub release failed with status: ${error.status}`);
|
||||||
|
console.log(`${JSON.stringify(error.response.data)}`);
|
||||||
|
|
||||||
|
switch (error.status) {
|
||||||
|
case 403:
|
||||||
|
console.log(
|
||||||
|
"Skip retry — your GitHub token/PAT does not have the required permission to create a release"
|
||||||
|
);
|
||||||
|
throw error;
|
||||||
|
|
||||||
|
case 404:
|
||||||
|
console.log("Skip retry - discussion category mismatch");
|
||||||
|
throw error;
|
||||||
|
|
||||||
|
case 422:
|
||||||
|
console.log("Skip retry - validation failed");
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`retrying... (${maxRetries - 1} retries remaining)`);
|
||||||
|
return release(config, releaser, maxRetries - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user