Skip to content

Commit

Permalink
Release: use buildDefaultFiles directly and pass version
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
timmywil committed Feb 6, 2024
1 parent 6376765 commit b507c86
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions build/release.js
Expand Up @@ -24,6 +24,7 @@ module.exports = function( Release ) {
];
const cdn = require( "./release/cdn" );
const dist = require( "./release/dist" );
const { buildDefaultFiles } = require( "./tasks/build" );

const npmTags = Release.npmTags;

Expand Down Expand Up @@ -53,8 +54,8 @@ module.exports = function( Release ) {
* committed before creating the tag.
* @param {Function} callback
*/
generateArtifacts: function( callback ) {
Release.exec( "npm run build:all" );
generateArtifacts: async function( callback ) {
await buildDefaultFiles( { version: Release.newVersion } );

cdn.makeReleaseCopies( Release );
Release._setSrcVersion();
Expand All @@ -77,7 +78,7 @@ module.exports = function( Release ) {
* Publish to distribution repo and npm
* @param {Function} callback
*/
dist: async callback => {
dist: async function( callback ) {
await cdn.makeArchives( Release );
dist( Release, distFiles, callback );
}
Expand Down
1 change: 1 addition & 0 deletions build/release/dist.js
Expand Up @@ -119,6 +119,7 @@ module.exports = function( Release, files, complete ) {
delete packageJson.devDependencies;
delete packageJson.dependencies;
delete packageJson.commitplease;
packageJson.version = Release.newVersion;
await fs.writeFile(
`${ Release.dir.dist }/package.json`,
JSON.stringify( packageJson, null, 2 )
Expand Down
5 changes: 4 additions & 1 deletion build/tasks/build.js
Expand Up @@ -352,7 +352,10 @@ async function build( {
}
}

async function buildDefaultFiles( { version, watch } = {} ) {
async function buildDefaultFiles( {
version = process.env.VERSION,
watch
} = {} ) {
await Promise.all( [
build( { version, watch } ),
build( { filename: "jquery.slim.js", slim: true, version, watch } ),
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/compare_size.mjs
Expand Up @@ -109,7 +109,7 @@ export async function compareSize( { cache = ".sizecache.json", files } = {} ) {
// Remove the short SHA and .dirty from comparisons.
// The short SHA so commits can be compared against each other
// 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" ), "" );

const size = Buffer.byteLength( contents, "utf8" );
Expand Down

0 comments on commit b507c86

Please sign in to comment.