@@ -55,31 +55,49 @@ export default async (pluginConfig, context) => {
5555 debug ( "milestones: %o" , milestones ) ;
5656
5757 if ( assets && assets . length > 0 ) {
58+ const templatedAssets = assets . map ( ( asset ) => {
59+ if ( isPlainObject ( asset ) ) {
60+ const templatedAsset = { ...asset } ;
61+ if ( asset . path ) {
62+ templatedAsset . path = Array . isArray ( asset . path )
63+ ? asset . path . map ( ( pattern ) => template ( pattern ) ( context ) )
64+ : template ( asset . path ) ( context ) ;
65+ }
66+ templatedAsset . url = asset . url ? template ( asset . url ) ( context ) : asset . url ;
67+ templatedAsset . label = asset . label ? template ( asset . label ) ( context ) : asset . label ;
68+ templatedAsset . type = asset . type ? template ( asset . type ) ( context ) : asset . type ;
69+ templatedAsset . filepath = asset . filepath ? template ( asset . filepath ) ( context ) : asset . filepath ;
70+ templatedAsset . target = asset . target ? template ( asset . target ) ( context ) : asset . target ;
71+ templatedAsset . status = asset . status ? template ( asset . status ) ( context ) : asset . status ;
72+ templatedAsset . packageName = asset . packageName ? template ( asset . packageName ) ( context ) : asset . packageName ;
73+ return templatedAsset ;
74+ } else if ( Array . isArray ( asset ) ) {
75+ // Handle array of glob patterns
76+ return asset . map ( ( pattern ) => template ( pattern ) ( context ) ) ;
77+ } else {
78+ // String asset path
79+ return template ( asset ) ( context ) ;
80+ }
81+ } ) ;
82+
5883 // Skip glob if url is provided
59- const urlAssets = assets . filter ( ( asset ) => asset . url ) ;
84+ const urlAssets = templatedAssets . filter ( ( asset ) => asset . url ) ;
6085 debug ( "url assets: %o" , urlAssets ) ;
6186 const globbedAssets = await getAssets (
6287 context ,
63- assets . filter ( ( asset ) => ! asset . url )
88+ templatedAssets . filter ( ( asset ) => ! asset . url )
6489 ) ;
6590 debug ( "globbed assets: %o" , globbedAssets ) ;
6691 const allAssets = [ ...urlAssets , ...globbedAssets ] ;
6792 debug ( "all assets: %o" , allAssets ) ;
6893
6994 await Promise . all (
7095 allAssets . map ( async ( asset ) => {
71- const path = template ( ( isPlainObject ( asset ) ? asset : { path : asset } ) . path ) ( context ) ;
72- const _url = asset . url ? template ( asset . url ) ( context ) : undefined ;
73- const label = asset . label ? template ( asset . label ) ( context ) : undefined ;
74- const type = asset . type ? template ( asset . type ) ( context ) : undefined ;
75- const filepath = asset . filepath ? template ( asset . filepath ) ( context ) : undefined ;
76- const target = asset . target ? template ( asset . target ) ( context ) : undefined ;
77- const status = asset . status ? template ( asset . status ) ( context ) : undefined ;
78- const packageName = asset . packageName ? template ( asset . packageName ) ( context ) : "release" ;
79-
80- if ( _url ) {
81- assetsList . push ( { label, rawUrl : _url , type, filepath } ) ;
82- debug ( "use link from release setting: %s" , _url ) ;
96+ const path = isPlainObject ( asset ) ? asset . path : asset ;
97+
98+ if ( asset . url ) {
99+ assetsList . push ( { label : asset . label , rawUrl : asset . url , type : asset . type , filepath : asset . filepath } ) ;
100+ debug ( "use link from release setting: %s" , asset . url ) ;
83101 } else {
84102 const file = pathlib . resolve ( cwd , path ) ;
85103
@@ -98,18 +116,19 @@ export default async (pluginConfig, context) => {
98116 }
99117
100118 debug ( "file path: %o" , path ) ;
101- debug ( "file label: %o" , label ) ;
102- debug ( "file type: %o" , type ) ;
103- debug ( "file filepath: %o" , filepath ) ;
104- debug ( "file target: %o" , target ) ;
105- debug ( "file status: %o" , status ) ;
106- debug ( "package name: %o" , packageName ) ;
119+ debug ( "file label: %o" , asset . label ) ;
120+ debug ( "file type: %o" , asset . type ) ;
121+ debug ( "file filepath: %o" , asset . filepath ) ;
122+ debug ( "file target: %o" , asset . target ) ;
123+ debug ( "file status: %o" , asset . status ) ;
124+ debug ( "package name: %o" , asset . packageName ) ;
107125
108126 let uploadEndpoint ;
109127 let response ;
110128
111- if ( target === "generic_package" ) {
112- const finalLabel = label ?? pathlib . basename ( file ) ;
129+ if ( asset . target === "generic_package" ) {
130+ const finalLabel = asset . label ?? pathlib . basename ( file ) ;
131+ const packageName = asset . packageName ?? "release" ;
113132 // Upload generic packages
114133 const encodedVersion = encodeURIComponent ( version ) ;
115134 const encodedPackageName = encodeURIComponent ( packageName ) ;
@@ -118,7 +137,7 @@ export default async (pluginConfig, context) => {
118137 uploadEndpoint = urlJoin (
119138 projectApiUrl ,
120139 `packages/generic/${ encodedPackageName } /${ encodedVersion } /${ encodedLabel } ?${
121- status ? `status=${ status } &` : ""
140+ asset . status ? `status=${ asset . status } &` : ""
122141 } select=package_file`
123142 ) ;
124143
@@ -137,7 +156,7 @@ export default async (pluginConfig, context) => {
137156 `packages/generic/${ encodedPackageName } /${ encodedVersion } /${ encodedLabel } `
138157 ) ;
139158
140- assetsList . push ( { label : finalLabel , alt : packageName , url, type : "package" , filepath } ) ;
159+ assetsList . push ( { label : finalLabel , alt : packageName , url, type : "package" , filepath : asset . filepath } ) ;
141160
142161 logger . log ( "Uploaded file: %s (%s)" , url , response . file . url ) ;
143162 } else {
@@ -158,7 +177,7 @@ export default async (pluginConfig, context) => {
158177 const { alt, full_path } = response ;
159178 const url = urlJoin ( gitlabUrl , full_path ) ;
160179
161- assetsList . push ( { label, alt, url, type, filepath } ) ;
180+ assetsList . push ( { label : asset . label , alt, url, type : asset . type , filepath : asset . filepath } ) ;
162181
163182 logger . log ( "Uploaded file: %s" , url ) ;
164183 }
0 commit comments