Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
69320dbe05 | |||
9771ccf55f | |||
0a76e4214a | |||
3989e4b325 | |||
72e945e627 | |||
40bf9ec7aa | |||
998623f0c3 | |||
0979303f02 | |||
9b795e5782 |
@ -1,3 +1,8 @@
|
|||||||
|
## 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)
|
||||||
|
- Improvements to error handling [#449](https://github.com/softprops/action-gh-release/pull/449) via [@till](https://github.com/till)
|
||||||
|
|
||||||
## 2.0.4
|
## 2.0.4
|
||||||
|
|
||||||
- Minor follow up to [#417](https://github.com/softprops/action-gh-release/pull/417). [#425](https://github.com/softprops/action-gh-release/pull/425)
|
- Minor follow up to [#417](https://github.com/softprops/action-gh-release/pull/417). [#425](https://github.com/softprops/action-gh-release/pull/425)
|
||||||
|
@ -154,11 +154,10 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
body_path: ${{ github.workspace }}-CHANGELOG.txt
|
body_path: ${{ github.workspace }}-CHANGELOG.txt
|
||||||
|
repository: my_gh_org/my_gh_repo
|
||||||
# note you'll typically need to create a personal access token
|
# note you'll typically need to create a personal access token
|
||||||
# with permissions to create releases in the other repo
|
# with permissions to create releases in the other repo
|
||||||
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
|
||||||
env:
|
|
||||||
GITHUB_REPOSITORY: my_gh_org/my_gh_repo
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 💅 Customizing
|
### 💅 Customizing
|
||||||
|
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",
|
"name": "action-gh-release",
|
||||||
"version": "2.0.3",
|
"version": "2.0.5",
|
||||||
"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",
|
||||||
|
102
src/github.ts
102
src/github.ts
@ -149,7 +149,10 @@ export const upload = async (
|
|||||||
const [owner, repo] = config.github_repository.split("/");
|
const [owner, repo] = config.github_repository.split("/");
|
||||||
const { name, size, mime, data: body } = asset(path);
|
const { name, size, mime, data: body } = asset(path);
|
||||||
const currentAsset = currentAssets.find(
|
const currentAsset = currentAssets.find(
|
||||||
({ name: currentName }) => currentName == name
|
// note: GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List release assets" endpoint lists the renamed filenames.
|
||||||
|
// due to this renaming we need to be mindful when we compare the file name we're uploading with a name github may already have rewritten for logical comparison
|
||||||
|
// see https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset
|
||||||
|
({ name: currentName }) => currentName == name.replace(" ", ".")
|
||||||
);
|
);
|
||||||
if (currentAsset) {
|
if (currentAsset) {
|
||||||
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
console.log(`♻️ Deleting previously uploaded asset ${name}...`);
|
||||||
@ -278,52 +281,65 @@ export const release = async (
|
|||||||
});
|
});
|
||||||
return release.data;
|
return release.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status === 404) {
|
if (error.status !== 404) {
|
||||||
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 metrix runs
|
|
||||||
console.log(
|
|
||||||
`⚠️ GitHub release failed with status: ${
|
|
||||||
error.status
|
|
||||||
}\n${JSON.stringify(error.response.data.errors)}\nretrying... (${
|
|
||||||
maxRetries - 1
|
|
||||||
} retries remaining)`
|
|
||||||
);
|
|
||||||
return release(config, releaser, maxRetries - 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(
|
console.log(
|
||||||
`⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`
|
`⚠️ Unexpected error fetching GitHub release for tag ${config.github_ref}: ${error}`
|
||||||
);
|
);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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