mirror of
https://github.com/softprops/action-gh-release
synced 2025-09-22 03:38:53 +00:00
Compare commits
6 commits
e27c83a834
...
babd6e61fe
Author | SHA1 | Date | |
---|---|---|---|
![]() |
babd6e61fe | ||
![]() |
1fa29582bb | ||
![]() |
1e7fd8c9f7 | ||
![]() |
c9fa1ee1e1 | ||
![]() |
1080adb44e | ||
![]() |
bd82c38418 |
8 changed files with 84 additions and 78 deletions
|
@ -10,6 +10,7 @@ import {
|
|||
} from '../src/util';
|
||||
|
||||
import { assert, describe, expect, it } from 'vitest';
|
||||
import * as path from 'path';
|
||||
|
||||
describe('util', () => {
|
||||
describe('uploadUrl', () => {
|
||||
|
@ -385,7 +386,7 @@ describe('util', () => {
|
|||
describe('paths', () => {
|
||||
it('resolves files given a set of paths', async () => {
|
||||
assert.deepStrictEqual(paths(['tests/data/**/*', 'tests/data/does/not/exist/*']), [
|
||||
'tests/data/foo/bar.txt',
|
||||
path.join('tests', 'data', 'foo', 'bar.txt'),
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,64 +3,11 @@ import { statSync } from 'fs';
|
|||
import { open } from 'fs/promises';
|
||||
import { lookup } from 'mime-types';
|
||||
import { basename } from 'path';
|
||||
import { alignAssetName, Config, isTag, releaseBody } from './util';
|
||||
import { alignAssetName, isTag, releaseBody } from './util';
|
||||
import { ReleaseAsset, Config, Releaser, Release } from './interfaces';
|
||||
|
||||
type GitHub = InstanceType<typeof GitHub>;
|
||||
|
||||
export interface ReleaseAsset {
|
||||
name: string;
|
||||
mime: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
id: number;
|
||||
upload_url: string;
|
||||
html_url: string;
|
||||
tag_name: string;
|
||||
name: string | null;
|
||||
body?: string | null | undefined;
|
||||
target_commitish: string;
|
||||
draft: boolean;
|
||||
prerelease: boolean;
|
||||
assets: Array<{ id: number; name: string }>;
|
||||
}
|
||||
|
||||
export interface Releaser {
|
||||
getReleaseByTag(params: { owner: string; repo: string; tag: string }): Promise<{ data: Release }>;
|
||||
|
||||
createRelease(params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
tag_name: string;
|
||||
name: string;
|
||||
body: string | undefined;
|
||||
draft: boolean | undefined;
|
||||
prerelease: boolean | undefined;
|
||||
target_commitish: string | undefined;
|
||||
discussion_category_name: string | undefined;
|
||||
generate_release_notes: boolean | undefined;
|
||||
make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}): Promise<{ data: Release }>;
|
||||
|
||||
updateRelease(params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
release_id: number;
|
||||
tag_name: string;
|
||||
target_commitish: string;
|
||||
name: string;
|
||||
body: string | undefined;
|
||||
draft: boolean | undefined;
|
||||
prerelease: boolean | undefined;
|
||||
discussion_category_name: string | undefined;
|
||||
generate_release_notes: boolean | undefined;
|
||||
make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}): Promise<{ data: Release }>;
|
||||
|
||||
allReleases(params: { owner: string; repo: string }): AsyncIterableIterator<{ data: Release[] }>;
|
||||
}
|
||||
|
||||
export class GitHubReleaser implements Releaser {
|
||||
github: GitHub;
|
||||
constructor(github: GitHub) {
|
||||
|
|
22
src/interfaces/configInterface.ts
Normal file
22
src/interfaces/configInterface.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
export interface Config {
|
||||
github_token: string;
|
||||
github_ref: string;
|
||||
github_repository: string;
|
||||
// user provided
|
||||
input_name?: string;
|
||||
input_tag_name?: string;
|
||||
input_repository?: string;
|
||||
input_body?: string;
|
||||
input_body_path?: string;
|
||||
input_files?: string[];
|
||||
input_overwrite_files?: boolean;
|
||||
input_draft?: boolean;
|
||||
input_preserve_order?: boolean;
|
||||
input_prerelease?: boolean;
|
||||
input_fail_on_unmatched_files?: boolean;
|
||||
input_target_commitish?: string;
|
||||
input_discussion_category_name?: string;
|
||||
input_generate_release_notes?: boolean;
|
||||
input_append_body?: boolean;
|
||||
input_make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}
|
4
src/interfaces/index.ts
Normal file
4
src/interfaces/index.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export * from './configInterface';
|
||||
export * from './releaserInterface';
|
||||
export * from './releaseAssetInterface';
|
||||
export * from './releaseInterface';
|
5
src/interfaces/releaseAssetInterface.ts
Normal file
5
src/interfaces/releaseAssetInterface.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export interface ReleaseAsset {
|
||||
name: string;
|
||||
mime: string;
|
||||
size: number;
|
||||
}
|
12
src/interfaces/releaseInterface.ts
Normal file
12
src/interfaces/releaseInterface.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
export interface Release {
|
||||
id: number;
|
||||
upload_url: string;
|
||||
html_url: string;
|
||||
tag_name: string;
|
||||
name: string | null;
|
||||
body?: string | null | undefined;
|
||||
target_commitish: string;
|
||||
draft: boolean;
|
||||
prerelease: boolean;
|
||||
assets: Array<{ id: number; name: string }>;
|
||||
}
|
36
src/interfaces/releaserInterface.ts
Normal file
36
src/interfaces/releaserInterface.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { Release } from './releaseInterface';
|
||||
|
||||
export interface Releaser {
|
||||
getReleaseByTag(params: { owner: string; repo: string; tag: string }): Promise<{ data: Release }>;
|
||||
|
||||
createRelease(params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
tag_name: string;
|
||||
name: string;
|
||||
body: string | undefined;
|
||||
draft: boolean | undefined;
|
||||
prerelease: boolean | undefined;
|
||||
target_commitish: string | undefined;
|
||||
discussion_category_name: string | undefined;
|
||||
generate_release_notes: boolean | undefined;
|
||||
make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}): Promise<{ data: Release }>;
|
||||
|
||||
updateRelease(params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
release_id: number;
|
||||
tag_name: string;
|
||||
target_commitish: string;
|
||||
name: string;
|
||||
body: string | undefined;
|
||||
draft: boolean | undefined;
|
||||
prerelease: boolean | undefined;
|
||||
discussion_category_name: string | undefined;
|
||||
generate_release_notes: boolean | undefined;
|
||||
make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}): Promise<{ data: Release }>;
|
||||
|
||||
allReleases(params: { owner: string; repo: string }): AsyncIterableIterator<{ data: Release[] }>;
|
||||
}
|
23
src/util.ts
23
src/util.ts
|
@ -1,28 +1,7 @@
|
|||
import * as glob from 'glob';
|
||||
import { statSync, readFileSync } from 'fs';
|
||||
|
||||
export interface Config {
|
||||
github_token: string;
|
||||
github_ref: string;
|
||||
github_repository: string;
|
||||
// user provided
|
||||
input_name?: string;
|
||||
input_tag_name?: string;
|
||||
input_repository?: string;
|
||||
input_body?: string;
|
||||
input_body_path?: string;
|
||||
input_files?: string[];
|
||||
input_overwrite_files?: boolean;
|
||||
input_draft?: boolean;
|
||||
input_preserve_order?: boolean;
|
||||
input_prerelease?: boolean;
|
||||
input_fail_on_unmatched_files?: boolean;
|
||||
input_target_commitish?: string;
|
||||
input_discussion_category_name?: string;
|
||||
input_generate_release_notes?: boolean;
|
||||
input_append_body?: boolean;
|
||||
input_make_latest: 'true' | 'false' | 'legacy' | undefined;
|
||||
}
|
||||
import { Config } from './interfaces';
|
||||
|
||||
export const uploadUrl = (url: string): string => {
|
||||
const templateMarkerPos = url.indexOf('{');
|
||||
|
|
Loading…
Reference in a new issue