diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfd72d99f..cbd81abf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,7 +59,7 @@ jobs: run: | pnpm install --fetch-timeout 100000 # TODO use the built output from a previous frontend build step - node build.js "${{ steps.ghd.outputs.describe }}" + node build.js "${{ steps.ghd.outputs.describe }}" ${{ github.ref_type == 'tag' }} - name: Store release as artifact uses: actions/upload-artifact@v4 with: diff --git a/desktop/build.js b/desktop/build.js index 2e1845924..bc63c77db 100644 --- a/desktop/build.js +++ b/desktop/build.js @@ -52,16 +52,32 @@ async function replaceTextInFile(filePath, searchValue, replaceValue) { await fs.promises.writeFile(filePath, result, 'utf8'); } +async function renameDistFilesToUnstable(currentVersion) { + const directory = 'dist'; + const files = await fs.promises.readdir(directory); + for (const file of files) { + if (file.includes(currentVersion)) { + const newName = file.replace(currentVersion, 'unstable'); + await fs.promises.rename( + path.join(directory, file), + path.join(directory, newName) + ); + console.log(`Renamed: ${file} -> ${newName}`); + } + } +} + // Main function to execute the script steps async function main() { const args = process.argv.slice(2); if (args.length === 0) { console.error("Error: Version placeholder argument is required."); - console.error("Usage: node build-script.js "); + console.error("Usage: node build-script.js [rename-version]"); process.exit(1); } const versionPlaceholder = args[0]; + const renameDistFiles = args[1] || false; const frontendZipUrl = "https://dl.vikunja.io/frontend/vikunja-frontend-unstable.zip"; const zipFilePath = path.resolve(__dirname, 'vikunja-frontend-unstable.zip'); const frontendDir = path.resolve(__dirname, 'frontend'); @@ -91,6 +107,11 @@ async function main() { console.log('Step 5: Installing dependencies and building...'); execSync('pnpm dist', { stdio: 'inherit' }); + if (renameDistFiles) { + console.log('Step 6: Renaming release files...'); + await renameDistFilesToUnstable(versionPlaceholder); + } + console.log('All steps completed successfully!'); } catch (err) { console.error('An error occurred:', err.message);