Release: use buildDefaultFiles directly and pass version

- also add the ability to pass VERSION in env to test final builds
- adjust sha regex to account for lack of shas
- set the version on the dist package.json

Close gh-5408
This commit is contained in:
Timmy Willison 2024-02-06 09:53:30 -05:00 committed by GitHub
parent 63767650b5
commit b507c8648f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 5 deletions

View File

@ -24,6 +24,7 @@ module.exports = function( Release ) {
]; ];
const cdn = require( "./release/cdn" ); const cdn = require( "./release/cdn" );
const dist = require( "./release/dist" ); const dist = require( "./release/dist" );
const { buildDefaultFiles } = require( "./tasks/build" );
const npmTags = Release.npmTags; const npmTags = Release.npmTags;
@ -53,8 +54,8 @@ module.exports = function( Release ) {
* committed before creating the tag. * committed before creating the tag.
* @param {Function} callback * @param {Function} callback
*/ */
generateArtifacts: function( callback ) { generateArtifacts: async function( callback ) {
Release.exec( "npm run build:all" ); await buildDefaultFiles( { version: Release.newVersion } );
cdn.makeReleaseCopies( Release ); cdn.makeReleaseCopies( Release );
Release._setSrcVersion(); Release._setSrcVersion();
@ -77,7 +78,7 @@ module.exports = function( Release ) {
* Publish to distribution repo and npm * Publish to distribution repo and npm
* @param {Function} callback * @param {Function} callback
*/ */
dist: async callback => { dist: async function( callback ) {
await cdn.makeArchives( Release ); await cdn.makeArchives( Release );
dist( Release, distFiles, callback ); dist( Release, distFiles, callback );
} }

View File

@ -119,6 +119,7 @@ module.exports = function( Release, files, complete ) {
delete packageJson.devDependencies; delete packageJson.devDependencies;
delete packageJson.dependencies; delete packageJson.dependencies;
delete packageJson.commitplease; delete packageJson.commitplease;
packageJson.version = Release.newVersion;
await fs.writeFile( await fs.writeFile(
`${ Release.dir.dist }/package.json`, `${ Release.dir.dist }/package.json`,
JSON.stringify( packageJson, null, 2 ) JSON.stringify( packageJson, null, 2 )

View File

@ -352,7 +352,10 @@ async function build( {
} }
} }
async function buildDefaultFiles( { version, watch } = {} ) { async function buildDefaultFiles( {
version = process.env.VERSION,
watch
} = {} ) {
await Promise.all( [ await Promise.all( [
build( { version, watch } ), build( { version, watch } ),
build( { filename: "jquery.slim.js", slim: true, version, watch } ), build( { filename: "jquery.slim.js", slim: true, version, watch } ),

View File

@ -109,7 +109,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
// Remove the short SHA and .dirty from comparisons. // Remove the short SHA and .dirty from comparisons.
// The short SHA so commits can be compared against each other // The short SHA so commits can be compared against each other
// and .dirty to compare with the existing branch during development. // and .dirty to compare with the existing branch during development.
const sha = /jQuery v\d+.\d+.\d+(?:-\w+)?\+(?:slim.)?([^ \.]+(?:\.dirty)?)/.exec( contents )[ 1 ]; const sha = /jQuery v\d+.\d+.\d+(?:-\w+)?(?:\+|\+slim\.)?([^ \.]+(?:\.dirty)?)?/.exec( contents )[ 1 ];
contents = contents.replace( new RegExp( sha, "g" ), "" ); contents = contents.replace( new RegExp( sha, "g" ), "" );
const size = Buffer.byteLength( contents, "utf8" ); const size = Buffer.byteLength( contents, "utf8" );