async function buildRelease( { version } ) {
	const releaseFolder = path.join( "tmp/verify", version );

	// Clone the release repo
	console.log( `Cloning jQuery ${ version }...` );
	await rimraf( releaseFolder );
	await mkdir( releaseFolder, { recursive: true } );

	// Uses a depth of 2 so we can get the commit date of
	// the commit used to build, which is the commit before the tag
	await exec(
		`git clone -q -b ${ version } --depth=2 ${ SRC_REPO } ${ releaseFolder }`
	);

	// Install node dependencies
	console.log( `Installing dependencies for jQuery ${ version }...` );
	await exec( "npm ci", { cwd: releaseFolder } );

	// Find the date of the commit just before the release,
	// which was used as the date in the built files
	const { stdout: date } = await exec( "git log -1 --format=%ci HEAD~1", {
		cwd: releaseFolder
	} );

	// Build the release
	console.log( `Building jQuery ${ version }...` );
	const { stdout: buildOutput } = await exec( "npm run build:all", {
		cwd: releaseFolder,
		env: {

			// Keep existing environment variables
			...process.env,
			RELEASE_DATE: date,
			VERSION: version
		}
	} );
	console.log( buildOutput );

	// Pack the npm tarball
	console.log( `Packing jQuery ${ version }...` );
	const { stdout: packOutput } = await exec( "npm pack", { cwd: releaseFolder } );
	console.log( packOutput );

	// Get all top-level /dist and /dist-module files
	const distFiles = await readdir(
		path.join( releaseFolder, "dist" ),
		{ withFileTypes: true }
	);
	const distModuleFiles = await readdir(
		path.join( releaseFolder, "dist-module" ),
		{ withFileTypes: true }
	);

	const files = await Promise.all(
		[ ...distFiles, ...distModuleFiles ]
			.filter( ( dirent ) => dirent.isFile() )
			.map( async( dirent ) => {
				const contents = await readFile(
					path.join( dirent.parentPath, dirent.name ),
					"utf8"
				);
				return {
					name: dirent.name,
					path: path.basename( dirent.parentPath ),
					contents,
					cdnName: dirent.name.replace( rjquery, `jquery-${ version }` ),
					cdnContents: dirent.name.endsWith( ".map" ) ?

						// The CDN has versioned filenames in the maps
						convertMapToVersioned( contents, version ) :
						contents
				};
			} )
	);

	// Get checksum of the tarball
	const tgzFilename = `jquery-${ version }.tgz`;
	const sum = await sumTarball( path.join( releaseFolder, tgzFilename ) );

	return {
		files,
		tgz: {
			name: tgzFilename,
			contents: sum
		},
		version
	};
}
Verify the latest release is reproducible