diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2a923f6b3f..77228993c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -160,6 +160,16 @@ jobs: path: ./packages/cli/skills if-no-files-found: error + - name: Upload LICENSE files + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} + with: + name: licenses + path: | + ./packages/core/LICENSE + ./packages/cli/LICENSE + if-no-files-found: error + Release: runs-on: ubuntu-latest needs: [prepare, build-rust] @@ -212,6 +222,13 @@ jobs: pattern: core merge-multiple: true + - name: Download LICENSE files + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + path: packages + pattern: licenses + merge-multiple: true + - uses: ./.github/actions/download-rolldown-binaries with: github-token: ${{ github.token }} diff --git a/packages/core/.gitignore b/packages/core/.gitignore index 2acb14babf..9dc7e3d4a9 100644 --- a/packages/core/.gitignore +++ b/packages/core/.gitignore @@ -1,2 +1 @@ /LICENSE -/LICENSE.md diff --git a/packages/core/build.ts b/packages/core/build.ts index 96285ef403..4c0a9e0273 100644 --- a/packages/core/build.ts +++ b/packages/core/build.ts @@ -55,7 +55,7 @@ await bundleVitepress(); generateLicenseFile({ title: 'Vite-Plus core license', packageName: 'Vite-Plus', - outputPath: join(projectDir, 'LICENSE.md'), + outputPath: join(projectDir, 'LICENSE'), coreLicensePath: join(projectDir, '..', '..', 'LICENSE'), bundledPaths: [join(projectDir, 'dist')], resolveFrom: [ @@ -84,11 +84,10 @@ generateLicenseFile({ }, ], }); -if (!existsSync(join(projectDir, 'LICENSE.md'))) { - throw new Error('LICENSE.md was not generated during build'); +if (!existsSync(join(projectDir, 'LICENSE'))) { + throw new Error('LICENSE was not generated during build'); } await mergePackageJson(); -await syncLicenseFromRoot(); async function buildVite() { const newViteRolldownConfig = viteRolldownConfig.map((config) => { @@ -670,9 +669,3 @@ async function mergePackageJson() { } await writeFile(destPkgPath, code); } - -async function syncLicenseFromRoot() { - const rootLicensePath = join(projectDir, '..', '..', 'LICENSE'); - const packageLicensePath = join(projectDir, 'LICENSE'); - await copyFile(rootLicensePath, packageLicensePath); -} diff --git a/packages/test/build.ts b/packages/test/build.ts index 9f2d1cf3da..444963eec7 100644 --- a/packages/test/build.ts +++ b/packages/test/build.ts @@ -231,7 +231,7 @@ await mergePackageJson(pluginExports); generateLicenseFile({ title: 'Vite-Plus test license', packageName: 'Vite-Plus', - outputPath: join(projectDir, 'LICENSE.md'), + outputPath: join(projectDir, 'LICENSE'), coreLicensePath: join(projectDir, '..', '..', 'LICENSE'), bundledPaths: [distDir], resolveFrom: [projectDir, join(projectDir, '..', '..')], @@ -242,10 +242,9 @@ generateLicenseFile({ })), ], }); -if (!existsSync(join(projectDir, 'LICENSE.md'))) { - throw new Error('LICENSE.md was not generated during build'); +if (!existsSync(join(projectDir, 'LICENSE'))) { + throw new Error('LICENSE was not generated during build'); } -await syncLicenseFromRoot(); await validateExternalDeps(); async function mergePackageJson(pluginExports: Array<{ exportPath: string; shimFile: string }>) { @@ -434,12 +433,6 @@ async function mergePackageJson(pluginExports: Array<{ exportPath: string; shimF await writeFile(destPackageJsonPath, code); } -async function syncLicenseFromRoot() { - const rootLicensePath = join(projectDir, '..', '..', 'LICENSE'); - const packageLicensePath = join(projectDir, 'LICENSE'); - await copyFile(rootLicensePath, packageLicensePath); -} - async function bundleVitest() { const vitestDestDir = projectDir; @@ -451,6 +444,7 @@ async function bundleVitest() { join(vitestSourceDir, 'node_modules/**'), join(vitestSourceDir, 'package.json'), join(vitestSourceDir, 'README.md'), + join(vitestSourceDir, 'LICENSE.md'), ], }); diff --git a/scripts/generate-license.ts b/scripts/generate-license.ts index 5e7d964f70..f7c67cfd22 100644 --- a/scripts/generate-license.ts +++ b/scripts/generate-license.ts @@ -203,7 +203,10 @@ export function generateLicenseFile(options: GenerateLicenseFileOptions) { if (existingContent !== licenseFileContent) { fs.writeFileSync(options.outputPath, licenseFileContent); - console.error('\x1b[33m\nLICENSE.md updated. You should commit the updated file.\n\x1b[0m'); + const outputFileName = path.basename(options.outputPath); + console.error( + `\x1b[33m\n${outputFileName} updated. You should commit the updated file.\n\x1b[0m`, + ); } }