Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5382d3e6f | |||
a0e2122208 | |||
8836085300 | |||
86463358d8 | |||
46b284799f | |||
37fd9d0351 | |||
39ba0b9d81 | |||
da05d55257 | |||
6b18c2f260 | |||
e2b105c98e | |||
e707470492 | |||
36833a1c71 | |||
8bb7207875 | |||
93bb5ff43e | |||
581b12c87f | |||
b540ad2354 | |||
ac224e9440 | |||
ab50eebb64 | |||
670eb2f21a | |||
4b4d743a9b | |||
daffc988f2 | |||
ffb524fa90 | |||
a921960380 | |||
51cfd90a6d | |||
431939b21f | |||
3792cde6c4 | |||
1fd6f3f2b1 | |||
7e44a1f6a7 | |||
67b6c38432 | |||
c43d7637b9 | |||
c95fe14893 | |||
deddb09c64 | |||
33fcd69d45 | |||
01050bd877 | |||
92dffe6c28 |
15
.github/dependabot.yml
vendored
15
.github/dependabot.yml
vendored
@ -4,15 +4,30 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
npm:
|
||||
patterns:
|
||||
- "*"
|
||||
ignore:
|
||||
- dependency-name: node-fetch
|
||||
versions:
|
||||
- ">=3.0.0"
|
||||
# ignore mime and @types/mime per https://github.com/softprops/action-gh-release/pull/475
|
||||
- dependency-name: mime
|
||||
versions:
|
||||
- ">=4.0.0"
|
||||
- dependency-name: "@types/mime"
|
||||
versions:
|
||||
- ">=4.0.0"
|
||||
commit-message:
|
||||
prefix: "chore(deps)"
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
groups:
|
||||
github-actions:
|
||||
patterns:
|
||||
- "*"
|
||||
commit-message:
|
||||
prefix: "chore(deps)"
|
||||
|
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
|
||||
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
|
||||
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
|
||||
with:
|
||||
node-version-file: ".tool-versions"
|
||||
cache: "npm"
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ __tests__/runner/*
|
||||
# actions requires a node_modules dir https://github.com/actions/toolkit/blob/master/docs/javascript-action.md#publish-a-releasesv1-action
|
||||
# but its recommended not to check these in https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations
|
||||
node_modules
|
||||
coverage
|
||||
|
@ -1 +1 @@
|
||||
nodejs 20.15.1
|
||||
nodejs 24.2.0
|
||||
|
35
CHANGELOG.md
35
CHANGELOG.md
@ -1,3 +1,38 @@
|
||||
## 2.3.0
|
||||
|
||||
* Migrate from jest to vitest
|
||||
* Replace `mime` with `mime-types`
|
||||
* Bump to use node 24
|
||||
* Dependency updates
|
||||
|
||||
## 2.2.2
|
||||
|
||||
## What's Changed
|
||||
|
||||
### Bug fixes 🐛
|
||||
|
||||
* fix: updating release draft status from true to false by @galargh in https://github.com/softprops/action-gh-release/pull/316
|
||||
|
||||
### Other Changes 🔄
|
||||
|
||||
* chore: simplify ref_type test by @steinybot in https://github.com/softprops/action-gh-release/pull/598
|
||||
* fix(docs): clarify the default for tag_name by @muzimuzhi in https://github.com/softprops/action-gh-release/pull/599
|
||||
* test(release): add unit tests when searching for a release by @rwaskiewicz in https://github.com/softprops/action-gh-release/pull/603
|
||||
* dependency updates
|
||||
|
||||
## 2.2.1
|
||||
|
||||
## What's Changed
|
||||
|
||||
### Bug fixes 🐛
|
||||
|
||||
* fix: big file uploads by @xen0n in https://github.com/softprops/action-gh-release/pull/562
|
||||
|
||||
### Other Changes 🔄
|
||||
* chore(deps): bump @types/node from 22.10.1 to 22.10.2 by @dependabot in https://github.com/softprops/action-gh-release/pull/559
|
||||
* chore(deps): bump @types/node from 22.10.2 to 22.10.5 by @dependabot in https://github.com/softprops/action-gh-release/pull/569
|
||||
* chore: update error and warning messages for not matching files in files field by @ytimocin in https://github.com/softprops/action-gh-release/pull/568
|
||||
|
||||
## 2.2.0
|
||||
|
||||
## What's Changed
|
||||
|
@ -54,7 +54,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: github.ref_type == 'tag'
|
||||
```
|
||||
|
||||
You can also use push config tag filter
|
||||
@ -106,7 +106,7 @@ jobs:
|
||||
run: cat Release.txt
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: github.ref_type == 'tag'
|
||||
with:
|
||||
files: Release.txt
|
||||
```
|
||||
@ -130,7 +130,7 @@ jobs:
|
||||
run: cat Release.txt
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: github.ref_type == 'tag'
|
||||
with:
|
||||
files: |
|
||||
Release.txt
|
||||
@ -162,7 +162,7 @@ jobs:
|
||||
run: echo "# Good things have arrived" > ${{ github.workspace }}-CHANGELOG.txt
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
if: github.ref_type == 'tag'
|
||||
with:
|
||||
body_path: ${{ github.workspace }}-CHANGELOG.txt
|
||||
repository: my_gh_org/my_gh_repo
|
||||
|
@ -1,6 +1,13 @@
|
||||
import * as assert from "assert";
|
||||
import { text } from "stream/consumers";
|
||||
import { mimeOrDefault, asset } from "../src/github";
|
||||
import {
|
||||
mimeOrDefault,
|
||||
asset,
|
||||
Releaser,
|
||||
Release,
|
||||
findTagFromReleases,
|
||||
} from "../src/github";
|
||||
|
||||
import { describe, it } from "vitest";
|
||||
|
||||
describe("github", () => {
|
||||
describe("mimeOrDefault", () => {
|
||||
@ -14,11 +21,257 @@ describe("github", () => {
|
||||
|
||||
describe("asset", () => {
|
||||
it("derives asset info from a path", async () => {
|
||||
const { name, mime, size, data } = asset("tests/data/foo/bar.txt");
|
||||
const { name, mime, size } = asset("tests/data/foo/bar.txt");
|
||||
assert.equal(name, "bar.txt");
|
||||
assert.equal(mime, "text/plain");
|
||||
assert.equal(size, 10);
|
||||
assert.equal(await text(data), "release me");
|
||||
});
|
||||
});
|
||||
|
||||
describe("findTagFromReleases", () => {
|
||||
const owner = "owner";
|
||||
const repo = "repo";
|
||||
|
||||
const mockRelease: Release = {
|
||||
id: 1,
|
||||
upload_url: `https://api.github.com/repos/${owner}/${repo}/releases/1/assets`,
|
||||
html_url: `https://github.com/${owner}/${repo}/releases/tag/v1.0.0`,
|
||||
tag_name: "v1.0.0",
|
||||
name: "Test Release",
|
||||
body: "Test body",
|
||||
target_commitish: "main",
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
assets: [],
|
||||
} as const;
|
||||
|
||||
const mockReleaser: Releaser = {
|
||||
getReleaseByTag: () => Promise.reject("Not implemented"),
|
||||
createRelease: () => Promise.reject("Not implemented"),
|
||||
updateRelease: () => Promise.reject("Not implemented"),
|
||||
allReleases: async function* () {
|
||||
yield { data: [mockRelease] };
|
||||
},
|
||||
} as const;
|
||||
|
||||
describe("when the tag_name is not an empty string", () => {
|
||||
const targetTag = "v1.0.0";
|
||||
|
||||
it("finds a matching release in first batch of results", async () => {
|
||||
const targetRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: targetTag,
|
||||
};
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [targetRelease] };
|
||||
yield { data: [otherRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
targetTag,
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(result, targetRelease);
|
||||
});
|
||||
|
||||
it("finds a matching release in second batch of results", async () => {
|
||||
const targetRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: targetTag,
|
||||
};
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [otherRelease] };
|
||||
yield { data: [targetRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
targetTag,
|
||||
);
|
||||
assert.deepStrictEqual(result, targetRelease);
|
||||
});
|
||||
|
||||
it("returns undefined when a release is not found in any batch", async () => {
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [otherRelease] };
|
||||
yield { data: [otherRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
targetTag,
|
||||
);
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
});
|
||||
|
||||
it("returns undefined when no releases are returned", async () => {
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
targetTag,
|
||||
);
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the tag_name is an empty string", () => {
|
||||
const emptyTag = "";
|
||||
|
||||
it("finds a matching release in first batch of results", async () => {
|
||||
const targetRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: emptyTag,
|
||||
};
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [targetRelease] };
|
||||
yield { data: [otherRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
emptyTag,
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(result, targetRelease);
|
||||
});
|
||||
|
||||
it("finds a matching release in second batch of results", async () => {
|
||||
const targetRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: emptyTag,
|
||||
};
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [otherRelease] };
|
||||
yield { data: [targetRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
emptyTag,
|
||||
);
|
||||
assert.deepStrictEqual(result, targetRelease);
|
||||
});
|
||||
|
||||
it("returns undefined when a release is not found in any batch", async () => {
|
||||
const otherRelease = {
|
||||
...mockRelease,
|
||||
owner,
|
||||
repo,
|
||||
tag_name: "v1.0.1",
|
||||
};
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [otherRelease] };
|
||||
yield { data: [otherRelease] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
emptyTag,
|
||||
);
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
});
|
||||
|
||||
it("returns undefined when no releases are returned", async () => {
|
||||
const releaser = {
|
||||
...mockReleaser,
|
||||
allReleases: async function* () {
|
||||
yield { data: [] };
|
||||
},
|
||||
};
|
||||
|
||||
const result = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
emptyTag,
|
||||
);
|
||||
|
||||
assert.strictEqual(result, undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -10,6 +10,8 @@ import {
|
||||
} from "../src/util";
|
||||
import * as assert from "assert";
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
|
||||
describe("util", () => {
|
||||
describe("uploadUrl", () => {
|
||||
it("strips template", () => {
|
||||
|
@ -13,7 +13,7 @@ inputs:
|
||||
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.ref_name"
|
||||
required: false
|
||||
draft:
|
||||
description: "Creates a draft release. Defaults to false"
|
||||
|
19
dist/index.js
vendored
19
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,16 +0,0 @@
|
||||
import type { JestConfigWithTsJest } from 'ts-jest';
|
||||
|
||||
const config: JestConfigWithTsJest = {
|
||||
preset: 'ts-jest/presets/default-esm',
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest',
|
||||
},
|
||||
verbose: true,
|
||||
};
|
||||
|
||||
export default config;
|
5232
package-lock.json
generated
5232
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@ -1,13 +1,14 @@
|
||||
{
|
||||
"name": "action-gh-release",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.2",
|
||||
"private": true,
|
||||
"description": "GitHub Action for creating GitHub Releases",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "ncc build src/main.ts --minify",
|
||||
"build": "ncc build src/main.ts --minify --target es2022",
|
||||
"build-debug": "ncc build src/main.ts --v8-cache --source-map",
|
||||
"test": "jest",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest --coverage",
|
||||
"fmt": "prettier --write \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
||||
"fmtcheck": "prettier --check \"src/**/*.ts\" \"__tests__/**/*.ts\"",
|
||||
"updatetag": "git tag -d v2 && git push origin :v2 && git tag -a v2 -m '' && git push origin v2"
|
||||
@ -22,24 +23,22 @@
|
||||
"author": "softprops",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^6.0.0",
|
||||
"@octokit/plugin-retry": "^7.1.2",
|
||||
"@octokit/plugin-throttling": "^9.3.2",
|
||||
"glob": "^11.0.0",
|
||||
"mime": "^3.0.0"
|
||||
"@actions/github": "^6.0.1",
|
||||
"@octokit/plugin-retry": "^8.0.1",
|
||||
"@octokit/plugin-throttling": "^11.0.1",
|
||||
"glob": "^11.0.2",
|
||||
"mime-types": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/mime": "^3.0.1",
|
||||
"@types/node": "^22.10.1",
|
||||
"@types/mime-types": "^3.0.1",
|
||||
"@types/node": "^22.15.21",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-circus": "^29.3.1",
|
||||
"prettier": "3.4.2",
|
||||
"ts-jest": "^29.2.5",
|
||||
"@vitest/coverage-v8": "^3.1.4",
|
||||
"prettier": "3.5.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.7.2",
|
||||
"typescript-formatter": "^7.2.2"
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-formatter": "^7.2.2",
|
||||
"vitest": "^3.1.4"
|
||||
}
|
||||
}
|
||||
|
108
src/github.ts
108
src/github.ts
@ -1,7 +1,8 @@
|
||||
import { GitHub } from "@actions/github/lib/utils";
|
||||
import { Config, isTag, releaseBody, alignAssetName } from "./util";
|
||||
import { createReadStream, statSync, type ReadStream } from "fs";
|
||||
import { getType } from "mime";
|
||||
import { statSync } from "fs";
|
||||
import { open } from "fs/promises";
|
||||
import { lookup } from "mime-types";
|
||||
import { basename } from "path";
|
||||
|
||||
type GitHub = InstanceType<typeof GitHub>;
|
||||
@ -10,7 +11,6 @@ export interface ReleaseAsset {
|
||||
name: string;
|
||||
mime: string;
|
||||
size: number;
|
||||
data: ReadStream;
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
@ -145,12 +145,11 @@ export const asset = (path: string): ReleaseAsset => {
|
||||
name: basename(path),
|
||||
mime: mimeOrDefault(path),
|
||||
size: statSync(path).size,
|
||||
data: createReadStream(path, "binary"),
|
||||
};
|
||||
};
|
||||
|
||||
export const mimeOrDefault = (path: string): string => {
|
||||
return getType(path) || "application/octet-stream";
|
||||
return lookup(path) || "application/octet-stream";
|
||||
};
|
||||
|
||||
export const upload = async (
|
||||
@ -161,7 +160,7 @@ export const upload = async (
|
||||
currentAssets: Array<{ id: number; name: string }>,
|
||||
): Promise<any> => {
|
||||
const [owner, repo] = config.github_repository.split("/");
|
||||
const { name, size, mime, data: body } = asset(path);
|
||||
const { name, mime, size } = asset(path);
|
||||
const currentAsset = currentAssets.find(
|
||||
// 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
|
||||
@ -179,25 +178,31 @@ export const upload = async (
|
||||
console.log(`⬆️ Uploading ${name}...`);
|
||||
const endpoint = new URL(url);
|
||||
endpoint.searchParams.append("name", name);
|
||||
const resp = await github.request({
|
||||
method: "POST",
|
||||
url: endpoint.toString(),
|
||||
headers: {
|
||||
"content-length": `${size}`,
|
||||
"content-type": mime,
|
||||
authorization: `token ${config.github_token}`,
|
||||
},
|
||||
data: body,
|
||||
});
|
||||
const json = resp.data;
|
||||
if (resp.status !== 201) {
|
||||
throw new Error(
|
||||
`Failed to upload release asset ${name}. received status code ${
|
||||
resp.status
|
||||
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
||||
);
|
||||
const fh = await open(path);
|
||||
try {
|
||||
const resp = await github.request({
|
||||
method: "POST",
|
||||
url: endpoint.toString(),
|
||||
headers: {
|
||||
"content-length": `${size}`,
|
||||
"content-type": mime,
|
||||
authorization: `token ${config.github_token}`,
|
||||
},
|
||||
data: fh.readableWebStream(),
|
||||
});
|
||||
const json = resp.data;
|
||||
if (resp.status !== 201) {
|
||||
throw new Error(
|
||||
`Failed to upload release asset ${name}. received status code ${
|
||||
resp.status
|
||||
}\n${json.message}\n${JSON.stringify(json.errors)}`,
|
||||
);
|
||||
}
|
||||
console.log(`✅ Uploaded ${name}`);
|
||||
return json;
|
||||
} finally {
|
||||
await fh.close();
|
||||
}
|
||||
return json;
|
||||
};
|
||||
|
||||
export const release = async (
|
||||
@ -220,26 +225,14 @@ export const release = async (
|
||||
const discussion_category_name = config.input_discussion_category_name;
|
||||
const generate_release_notes = config.input_generate_release_notes;
|
||||
try {
|
||||
// you can't get a an existing draft by tag
|
||||
// so we must find one in the list of all releases
|
||||
let _release: Release | undefined = undefined;
|
||||
if (config.input_draft) {
|
||||
for await (const response of releaser.allReleases({
|
||||
owner,
|
||||
repo,
|
||||
})) {
|
||||
_release = response.data.find((release) => release.tag_name === tag);
|
||||
}
|
||||
} else {
|
||||
_release = (
|
||||
await releaser.getReleaseByTag({
|
||||
owner,
|
||||
repo,
|
||||
tag,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
if (_release === null || _release === undefined) {
|
||||
const _release: Release | undefined = await findTagFromReleases(
|
||||
releaser,
|
||||
owner,
|
||||
repo,
|
||||
tag,
|
||||
);
|
||||
|
||||
if (_release === undefined) {
|
||||
return await createRelease(
|
||||
tag,
|
||||
config,
|
||||
@ -333,6 +326,33 @@ export const release = async (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Finds a release by tag name from all a repository's releases.
|
||||
*
|
||||
* @param releaser - The GitHub API wrapper for release operations
|
||||
* @param owner - The owner of the repository
|
||||
* @param repo - The name of the repository
|
||||
* @param tag - The tag name to search for
|
||||
* @returns The release with the given tag name, or undefined if no release with that tag name is found
|
||||
*/
|
||||
export async function findTagFromReleases(
|
||||
releaser: Releaser,
|
||||
owner: string,
|
||||
repo: string,
|
||||
tag: string,
|
||||
): Promise<Release | undefined> {
|
||||
for await (const { data: releases } of releaser.allReleases({
|
||||
owner,
|
||||
repo,
|
||||
})) {
|
||||
const release = releases.find((release) => release.tag_name === tag);
|
||||
if (release) {
|
||||
return release;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function createRelease(
|
||||
tag: string,
|
||||
config: Config,
|
||||
|
@ -67,9 +67,13 @@ async function run() {
|
||||
const files = paths(config.input_files);
|
||||
if (files.length == 0) {
|
||||
if (config.input_fail_on_unmatched_files) {
|
||||
throw new Error(`⚠️ ${config.input_files} not include valid file.`);
|
||||
throw new Error(
|
||||
`⚠️ ${config.input_files} does not include a valid file.`,
|
||||
);
|
||||
} else {
|
||||
console.warn(`🤔 ${config.input_files} not include valid file.`);
|
||||
console.warn(
|
||||
`🤔 ${config.input_files} does not include a valid file.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const currentAssets = rel.assets;
|
||||
|
@ -3,8 +3,8 @@
|
||||
"useUnknownInCatchVariables": false,
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"target": "es2022",
|
||||
"module": "NodeNext",
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
@ -25,6 +25,7 @@
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"skipLibCheck": true,
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
@ -44,7 +45,7 @@
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
"types": ["vitest/globals"],
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
@ -60,5 +61,5 @@
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts", "jest.config.ts"]
|
||||
"exclude": ["node_modules", "**/*.test.ts", "vitest.config.ts"]
|
||||
}
|
||||
|
11
vitest.config.ts
Normal file
11
vitest.config.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'node',
|
||||
coverage: {
|
||||
reporter: ['text', 'lcov'],
|
||||
},
|
||||
include: ['__tests__/**/*.ts'],
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user