@@ -10,8 +10,25 @@ const { files, ...otherArgs } = require( 'yargs/yargs' )(
1010
1111const filesList = files . split ( ',' ) ;
1212
13- // Get repository name from GitHub Actions environment variable (format: owner/repo).
14- const repoName = process . env . GITHUB_REPOSITORY ?. split ( '/' ) [ 1 ] || 'unknown' ;
13+ if ( ! process . env . GITHUB_REPOSITORY ) {
14+ console . error (
15+ 'GITHUB_REPOSITORY is not set. This script must run inside GitHub Actions ' +
16+ 'so the release asset path can be resolved. Aborting before semantic-release ' +
17+ 'publishes a release without an attached ZIP.'
18+ ) ;
19+ process . exit ( 1 ) ;
20+ }
21+
22+ const [ repoOwner , repoName ] = process . env . GITHUB_REPOSITORY . split ( '/' ) ;
23+ if ( ! repoOwner || ! repoName ) {
24+ console . error (
25+ `GITHUB_REPOSITORY must be in "owner/repo" format; received "${ process . env . GITHUB_REPOSITORY } ". ` +
26+ 'Aborting before semantic-release publishes a release with an invalid asset path.'
27+ ) ;
28+ process . exit ( 1 ) ;
29+ }
30+
31+ const releaseAssetPath = `./release/${ repoName } .zip` ;
1532
1633utils . log ( `Releasing ${ repoName } …` ) ;
1734
@@ -20,7 +37,7 @@ const getConfig = ({ gitBranchName }) => {
2037 const githubConfig = {
2138 assets : [
2239 {
23- path : `./release/ ${ repoName } .zip` ,
40+ path : releaseAssetPath ,
2441 label : `${ repoName } .zip` ,
2542 } ,
2643 ] ,
@@ -97,6 +114,11 @@ const getConfig = ({ gitBranchName }) => {
97114 } ,
98115 ] ) ;
99116
117+ // Verify the release archive exists on disk after `release:archive` ran.
118+ // `@semantic-release/github` silently ignores missing assets, so without this
119+ // guard a misconfigured archive step would publish a release with no ZIP.
120+ config . prepare . push ( require . resolve ( './verify-release-asset.js' ) ) ;
121+
100122 // Unless on a hotfix or epic branch, add a commit that updates the files.
101123 if ( [ 'hotfix' , 'epic' ] . indexOf ( branchType ) === - 1 ) {
102124 let assets = filesList ;
0 commit comments