Skip to content

Commit 84a2a59

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feat/previus_tag
2 parents 4577bf1 + 5434409 commit 84a2a59

File tree

12 files changed

+930
-863
lines changed

12 files changed

+930
-863
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
build:
99
runs-on: ubuntu-24.04
1010
steps:
11-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
11+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
1212

13-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
13+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v4
1414
with:
1515
node-version-file: ".tool-versions"
1616
cache: "npm"

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
## 2.4.1
2+
3+
## What's Changed
4+
5+
### Other Changes 🔄
6+
7+
* fix(util): support brace expansion globs containing commas in parseInputFiles by @Copilot in https://github.com/softprops/action-gh-release/pull/672
8+
* fix: gracefully fallback to body when body_path cannot be read by @Copilot in https://github.com/softprops/action-gh-release/pull/671
9+
10+
## 2.4.0
11+
12+
## What's Changed
13+
14+
### Exciting New Features 🎉
15+
16+
* feat(action): respect working_directory for files globs by @stephenway in https://github.com/softprops/action-gh-release/pull/667
17+
18+
## 2.3.4
19+
20+
## What's Changed
21+
22+
### Bug fixes 🐛
23+
24+
* fix(action): handle 422 already_exists race condition by @stephenway in https://github.com/softprops/action-gh-release/pull/665
25+
26+
### Other Changes 🔄
27+
28+
- dependency updates
29+
30+
## 2.3.3
31+
32+
## What's Changed
33+
34+
### Exciting New Features 🎉
35+
36+
* feat: add input option `overwrite_files` by @asfernandes in https://github.com/softprops/action-gh-release/pull/343
37+
38+
### Other Changes 🔄
39+
40+
- dependency updates
41+
142
## 2.3.2
243

344
* fix: revert fs `readableWebStream` change

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Checkout
54-
uses: actions/checkout@v4
54+
uses: actions/checkout@v5
5555
- name: Release
5656
uses: softprops/action-gh-release@v2
5757
if: github.ref_type == 'tag'
@@ -72,7 +72,7 @@ jobs:
7272
runs-on: ubuntu-latest
7373
steps:
7474
- name: Checkout
75-
uses: actions/checkout@v4
75+
uses: actions/checkout@v5
7676
- name: Release
7777
uses: softprops/action-gh-release@v2
7878
```
@@ -99,7 +99,7 @@ jobs:
9999
runs-on: ubuntu-latest
100100
steps:
101101
- name: Checkout
102-
uses: actions/checkout@v4
102+
uses: actions/checkout@v5
103103
- name: Build
104104
run: echo ${{ github.sha }} > Release.txt
105105
- name: Test
@@ -123,7 +123,7 @@ jobs:
123123
runs-on: ubuntu-latest
124124
steps:
125125
- name: Checkout
126-
uses: actions/checkout@v4
126+
uses: actions/checkout@v5
127127
- name: Build
128128
run: echo ${{ github.sha }} > Release.txt
129129
- name: Test
@@ -157,7 +157,7 @@ jobs:
157157
runs-on: ubuntu-latest
158158
steps:
159159
- name: Checkout
160-
uses: actions/checkout@v4
160+
uses: actions/checkout@v5
161161
- name: Generate Changelog
162162
run: echo "# Good things have arrived" > ${{ github.workspace }}-CHANGELOG.txt
163163
- name: Release

__tests__/github.test.ts

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { asset, findTagFromReleases, mimeOrDefault, Release, Releaser } from '../src/github';
1+
import {
2+
asset,
3+
findTagFromReleases,
4+
mimeOrDefault,
5+
release,
6+
Release,
7+
Releaser,
8+
} from '../src/github';
29

310
import { assert, describe, it } from 'vitest';
411

@@ -227,4 +234,75 @@ describe('github', () => {
227234
});
228235
});
229236
});
237+
238+
describe('error handling', () => {
239+
it('handles 422 already_exists error gracefully', async () => {
240+
const mockReleaser: Releaser = {
241+
getReleaseByTag: () => Promise.reject('Not implemented'),
242+
createRelease: () =>
243+
Promise.reject({
244+
status: 422,
245+
response: { data: { errors: [{ code: 'already_exists' }] } },
246+
}),
247+
updateRelease: () =>
248+
Promise.resolve({
249+
data: {
250+
id: 1,
251+
upload_url: 'test',
252+
html_url: 'test',
253+
tag_name: 'v1.0.0',
254+
name: 'test',
255+
body: 'test',
256+
target_commitish: 'main',
257+
draft: false,
258+
prerelease: false,
259+
assets: [],
260+
},
261+
}),
262+
allReleases: async function* () {
263+
yield {
264+
data: [
265+
{
266+
id: 1,
267+
upload_url: 'test',
268+
html_url: 'test',
269+
tag_name: 'v1.0.0',
270+
name: 'test',
271+
body: 'test',
272+
target_commitish: 'main',
273+
draft: false,
274+
prerelease: false,
275+
assets: [],
276+
},
277+
],
278+
};
279+
},
280+
} as const;
281+
282+
const config = {
283+
github_token: 'test-token',
284+
github_ref: 'refs/tags/v1.0.0',
285+
github_repository: 'owner/repo',
286+
input_tag_name: undefined,
287+
input_name: undefined,
288+
input_body: undefined,
289+
input_body_path: undefined,
290+
input_files: [],
291+
input_draft: undefined,
292+
input_prerelease: undefined,
293+
input_preserve_order: undefined,
294+
input_overwrite_files: undefined,
295+
input_fail_on_unmatched_files: false,
296+
input_target_commitish: undefined,
297+
input_discussion_category_name: undefined,
298+
input_generate_release_notes: false,
299+
input_append_body: false,
300+
input_make_latest: undefined,
301+
};
302+
303+
const result = await release(config, mockReleaser, 1);
304+
assert.ok(result);
305+
assert.equal(result.id, 1);
306+
});
307+
});
230308
});

__tests__/util.test.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ describe('util', () => {
3939
'loom',
4040
]);
4141
});
42+
it('handles globs with brace groups containing commas', () => {
43+
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}\nfoo,bar'), [
44+
'./**/*.{exe,deb,tar.gz}',
45+
'foo',
46+
'bar',
47+
]);
48+
});
49+
it('handles single-line brace pattern correctly', () => {
50+
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb,tar.gz}'), [
51+
'./**/*.{exe,deb,tar.gz}',
52+
]);
53+
});
4254
});
4355
describe('releaseBody', () => {
4456
it('uses input body', () => {
@@ -113,6 +125,52 @@ describe('util', () => {
113125
}),
114126
);
115127
});
128+
it('falls back to body when body_path is missing', () => {
129+
assert.equal(
130+
releaseBody({
131+
github_ref: '',
132+
github_repository: '',
133+
github_token: '',
134+
input_body: 'fallback-body',
135+
input_body_path: '__tests__/does-not-exist.txt',
136+
input_draft: false,
137+
input_prerelease: false,
138+
input_files: [],
139+
input_overwrite_files: undefined,
140+
input_preserve_order: undefined,
141+
input_name: undefined,
142+
input_tag_name: undefined,
143+
input_target_commitish: undefined,
144+
input_discussion_category_name: undefined,
145+
input_generate_release_notes: false,
146+
input_make_latest: undefined,
147+
}),
148+
'fallback-body',
149+
);
150+
});
151+
it('returns undefined when body_path is missing and body is not provided', () => {
152+
assert.equal(
153+
releaseBody({
154+
github_ref: '',
155+
github_repository: '',
156+
github_token: '',
157+
input_body: undefined,
158+
input_body_path: '__tests__/does-not-exist.txt',
159+
input_draft: false,
160+
input_prerelease: false,
161+
input_files: [],
162+
input_overwrite_files: undefined,
163+
input_preserve_order: undefined,
164+
input_name: undefined,
165+
input_tag_name: undefined,
166+
input_target_commitish: undefined,
167+
input_discussion_category_name: undefined,
168+
input_generate_release_notes: false,
169+
input_make_latest: undefined,
170+
}),
171+
undefined,
172+
);
173+
});
116174
});
117175
describe('parseConfig', () => {
118176
it('parses basic config', () => {
@@ -131,6 +189,7 @@ describe('util', () => {
131189
github_ref: '',
132190
github_repository: '',
133191
github_token: '',
192+
input_working_directory: undefined,
134193
input_append_body: false,
135194
input_body: undefined,
136195
input_body_path: undefined,
@@ -160,6 +219,7 @@ describe('util', () => {
160219
github_ref: '',
161220
github_repository: '',
162221
github_token: '',
222+
input_working_directory: undefined,
163223
input_append_body: false,
164224
input_body: undefined,
165225
input_body_path: undefined,
@@ -188,6 +248,7 @@ describe('util', () => {
188248
github_ref: '',
189249
github_repository: '',
190250
github_token: '',
251+
input_working_directory: undefined,
191252
input_append_body: false,
192253
input_body: undefined,
193254
input_body_path: undefined,
@@ -217,6 +278,7 @@ describe('util', () => {
217278
github_ref: '',
218279
github_repository: '',
219280
github_token: '',
281+
input_working_directory: undefined,
220282
input_append_body: false,
221283
input_body: undefined,
222284
input_body_path: undefined,
@@ -250,6 +312,7 @@ describe('util', () => {
250312
github_ref: '',
251313
github_repository: '',
252314
github_token: 'env-token',
315+
input_working_directory: undefined,
253316
input_append_body: false,
254317
input_body: undefined,
255318
input_body_path: undefined,
@@ -280,6 +343,7 @@ describe('util', () => {
280343
github_ref: '',
281344
github_repository: '',
282345
github_token: 'input-token',
346+
input_working_directory: undefined,
283347
input_append_body: false,
284348
input_body: undefined,
285349
input_body_path: undefined,
@@ -309,6 +373,7 @@ describe('util', () => {
309373
github_ref: '',
310374
github_repository: '',
311375
github_token: '',
376+
input_working_directory: undefined,
312377
input_append_body: false,
313378
input_body: undefined,
314379
input_body_path: undefined,
@@ -337,6 +402,7 @@ describe('util', () => {
337402
github_ref: '',
338403
github_repository: '',
339404
github_token: '',
405+
input_working_directory: undefined,
340406
input_append_body: false,
341407
input_body: undefined,
342408
input_body_path: undefined,
@@ -365,6 +431,7 @@ describe('util', () => {
365431
github_ref: '',
366432
github_repository: '',
367433
github_token: '',
434+
input_working_directory: undefined,
368435
input_append_body: true,
369436
input_body: undefined,
370437
input_body_path: undefined,
@@ -400,6 +467,10 @@ describe('util', () => {
400467
'tests/data/foo/bar.txt',
401468
]);
402469
});
470+
471+
it('resolves files relative to working_directory', async () => {
472+
assert.deepStrictEqual(paths(['data/**/*'], 'tests'), ['tests/data/foo/bar.txt']);
473+
});
403474
});
404475

405476
describe('unmatchedPatterns', () => {
@@ -409,6 +480,12 @@ describe('util', () => {
409480
['tests/data/does/not/exist/*'],
410481
);
411482
});
483+
484+
it('resolves unmatched relative to working_directory', async () => {
485+
assert.deepStrictEqual(unmatchedPatterns(['data/does/not/exist/*'], 'tests'), [
486+
'data/does/not/exist/*',
487+
]);
488+
});
412489
});
413490

414491
describe('replaceSpacesWithDots', () => {
@@ -425,3 +502,36 @@ describe('util', () => {
425502
});
426503
});
427504
});
505+
506+
describe('parseInputFiles edge cases', () => {
507+
it('handles multiple brace groups on same line', () => {
508+
assert.deepStrictEqual(parseInputFiles('./**/*.{exe,deb},./dist/**/*.{zip,tar.gz}'), [
509+
'./**/*.{exe,deb}',
510+
'./dist/**/*.{zip,tar.gz}',
511+
]);
512+
});
513+
514+
it('handles nested braces', () => {
515+
assert.deepStrictEqual(parseInputFiles('path/{a,{b,c}}/file.txt'), ['path/{a,{b,c}}/file.txt']);
516+
});
517+
518+
it('handles empty comma-separated values', () => {
519+
assert.deepStrictEqual(parseInputFiles('foo,,bar'), ['foo', 'bar']);
520+
});
521+
522+
it('handles commas with spaces around braces', () => {
523+
assert.deepStrictEqual(parseInputFiles(' ./**/*.{exe,deb} , file.txt '), [
524+
'./**/*.{exe,deb}',
525+
'file.txt',
526+
]);
527+
});
528+
529+
it('handles mixed newlines and commas with braces', () => {
530+
assert.deepStrictEqual(parseInputFiles('file1.txt\n./**/*.{exe,deb},file2.txt\nfile3.txt'), [
531+
'file1.txt',
532+
'./**/*.{exe,deb}',
533+
'file2.txt',
534+
'file3.txt',
535+
]);
536+
});
537+
});

0 commit comments

Comments
 (0)