@@ -20,6 +20,9 @@ const validatedEnv = envSchema.parse(env);
2020const pluginName = "dynamix.unraid.net" as const ;
2121const startingDir = process . cwd ( ) ;
2222
23+ // Ensure that git is available
24+ await $ `git log -1 --pretty=%B` ;
25+
2326const createBuildDirectory = async ( ) => {
2427 await execSync ( `rm -rf deploy/pre-pack/*` ) ;
2528 await execSync ( `rm -rf deploy/release/*` ) ;
@@ -100,16 +103,15 @@ const buildTxz = async (): Promise<{
100103} ;
101104
102105const getStagingChangelogFromGit = async (
103- version : string
106+ apiVersion : string
104107) : Promise < string | null > => {
105108 try {
106109 const changelogStream = conventionalChangelog (
107110 {
108111 preset : "conventionalcommits" ,
109- releaseCount : 0 ,
110112 } ,
111113 {
112- version,
114+ version : apiVersion ,
113115 }
114116 ) ;
115117 let changelog = "" ;
@@ -161,13 +163,13 @@ const buildPlugin = async ({
161163 MAIN_TXZ = `https://preview.dl.unraid.net/unraid-api/pr/${ pr } /${ pluginName } -${ version } .txz` ;
162164 API_TGZ = `https://preview.dl.unraid.net/unraid-api/pr/${ pr } /unraid-api-${ process . env . API_VERSION } .tgz` ;
163165 PLUGIN_URL = `https://preview.dl.unraid.net/unraid-api/pr/${ pr } /${ pluginName } .plg` ;
164- RELEASE_NOTES = await getStagingChangelogFromGit ( version ) ;
166+ RELEASE_NOTES = await getStagingChangelogFromGit ( apiVersion ) ;
165167 break ;
166168 case "staging" :
167169 PLUGIN_URL = "https://stable.dl.unraid.net/unraid-api/&name;.plg" ;
168170 MAIN_TXZ = `https://preview.dl.unraid.net/unraid-api/${ pluginName } -${ version } .txz` ;
169171 API_TGZ = `https://preview.dl.unraid.net/unraid-api/unraid-api-${ process . env . API_VERSION } .tgz` ;
170- RELEASE_NOTES = await getStagingChangelogFromGit ( version ) ;
172+ RELEASE_NOTES = await getStagingChangelogFromGit ( apiVersion ) ;
171173 break ;
172174 }
173175
@@ -211,30 +213,35 @@ const buildPlugin = async ({
211213/**
212214 * Main build script
213215 */
214- await createBuildDirectory ( ) ;
215- const { sha256 : txzSha256 , version } = await buildTxz ( ) ;
216- const { API_VERSION , API_SHA256 , PR } = validatedEnv ;
217- await buildPlugin ( {
218- type : "staging" ,
219- txzSha256,
220- version,
221- apiVersion : API_VERSION ,
222- apiSha256 : API_SHA256 ,
223- } ) ;
224- if ( PR ) {
216+
217+ const main = async ( ) => {
218+ await createBuildDirectory ( ) ;
219+ const { sha256 : txzSha256 , version } = await buildTxz ( ) ;
220+ const { API_VERSION , API_SHA256 , PR } = validatedEnv ;
225221 await buildPlugin ( {
226- type : "pr " ,
222+ type : "staging " ,
227223 txzSha256,
228224 version,
229- pr : PR ,
230225 apiVersion : API_VERSION ,
231226 apiSha256 : API_SHA256 ,
232227 } ) ;
233- }
234- await buildPlugin ( {
235- type : "production" ,
236- txzSha256,
237- version,
238- apiVersion : API_VERSION ,
239- apiSha256 : API_SHA256 ,
240- } ) ;
228+ if ( PR ) {
229+ await buildPlugin ( {
230+ type : "pr" ,
231+ txzSha256,
232+ version,
233+ pr : PR ,
234+ apiVersion : API_VERSION ,
235+ apiSha256 : API_SHA256 ,
236+ } ) ;
237+ }
238+ await buildPlugin ( {
239+ type : "production" ,
240+ txzSha256,
241+ version,
242+ apiVersion : API_VERSION ,
243+ apiSha256 : API_SHA256 ,
244+ } ) ;
245+ } ;
246+
247+ await main ( ) ;
0 commit comments