-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Build: Don't commit the min file or version to main, add release process #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ tmp | |
|
||
npm-debug.log* | ||
|
||
/dist | ||
/node_modules | ||
|
||
# Ignore BrowserStack testing files | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
preReleaseBase: 1, | ||
hooks: { | ||
"before:init": "bash ./build/release/pre-release.sh", | ||
"after:version:bump": | ||
"sed -i 's/main\\/AUTHORS.txt/${version}\\/AUTHORS.txt/' package.json", | ||
"after:bump": "cross-env VERSION=${version} npm run build", | ||
"before:git:release": "git add -f dist/", | ||
"after:release": "echo 'Run the following to complete the release:' && " + | ||
"echo './build/release/post-release.sh $\{version}'" | ||
}, | ||
git: { | ||
commitMessage: "Release: ${version}", | ||
getLatestTagFromAllRefs: true, | ||
pushRepo: "[email protected]:jquery/jquery-mousewheel.git", | ||
requireBranch: "main", | ||
requireCleanWorkingDir: true | ||
}, | ||
github: { | ||
pushRepo: "[email protected]:jquery/jquery-mousewheel.git", | ||
release: true, | ||
tokenRef: "JQUERY_GITHUB_TOKEN" | ||
}, | ||
npm: { | ||
publish: true | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Mouse Wheel ChangeLog | ||
# Mouse Wheel Change Log | ||
|
||
## 3.2.2 | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
|
||
set -euo pipefail | ||
|
||
# $1: Version | ||
|
||
dist=tmp/release/dist | ||
|
||
if [[ -z "$1" ]] then | ||
echo "Version is not set (1st argument)" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$2" ]] then | ||
echo "Blog URL is not set (2nd argument)" | ||
exit 1 | ||
fi | ||
|
||
# Restore AUTHORS URL | ||
sed -i "s/$1\/AUTHORS.txt/main\/AUTHORS.txt/" package.json | ||
git add package.json | ||
|
||
# Remove built files from tracking. | ||
npm run build:clean | ||
git rm --cached -r dist/ | ||
git commit -m "Release: remove dist files from main branch" | ||
|
||
# Wait for confirmation from user to push changes | ||
read -p "Press enter to push changes to main branch" | ||
git push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -euo pipefail | ||
|
||
read -p "Press enter if you updated CHANGELOG.md; abort otherwise" | ||
|
||
# Install dependencies | ||
npm ci | ||
|
||
# Clean all release and build artifacts | ||
npm run build:clean | ||
|
||
# Run tests | ||
npm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import fs from "node:fs/promises"; | ||
import path from "node:path"; | ||
import { exec as nodeExec } from "node:child_process"; | ||
import util from "node:util"; | ||
import { minify } from "./minify.mjs"; | ||
|
||
const exec = util.promisify( nodeExec ); | ||
|
||
const pkg = JSON.parse( await fs.readFile( "./package.json", "utf8" ) ); | ||
|
||
async function isCleanWorkingDir() { | ||
const { stdout } = await exec( "git status --untracked-files=no --porcelain" ); | ||
return !stdout.trim(); | ||
} | ||
|
||
async function versionForDist( { srcPath, destPath, version } ) { | ||
const code = await fs.readFile( srcPath, "utf8" ); | ||
const compiledContents = code.replace( /@VERSION/g, version ); | ||
|
||
await fs.mkdir( path.dirname( destPath ), { recursive: true } ); | ||
await fs.writeFile( destPath, compiledContents ); | ||
console.log( `${ destPath } v${ version } created.` ); | ||
} | ||
|
||
export async function build( { version = process.env.VERSION } = {} ) { | ||
|
||
// Add the short commit hash to the version string | ||
// when the version is not for a release. | ||
if ( !version ) { | ||
const { stdout } = await exec( "git rev-parse --short HEAD" ); | ||
const isClean = await isCleanWorkingDir(); | ||
|
||
// "+SHA" is semantically correct | ||
// Add ".dirty" as well if the working dir is not clean | ||
version = `${ pkg.version }+${ stdout.trim() }${ | ||
isClean ? "" : ".dirty" | ||
}`; | ||
} | ||
|
||
await versionForDist( { | ||
srcPath: "src/jquery.mousewheel.js", | ||
destPath: "dist/jquery.mousewheel.js", | ||
version | ||
} ); | ||
|
||
await minify( { | ||
srcPath: "dist/jquery.mousewheel.js", | ||
destPath: "dist/jquery.mousewheel.min.js", | ||
version | ||
} ); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.