Skip to content

Commit

Permalink
Make NPMs get released to GitHub Packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sideshowbarker committed Jul 12, 2021
1 parent d9b83e5 commit 4c45ffc
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ NN XXX NNNN
- Release: All autopublished-on-push release artifacts are now released
under the tag `latest`; no more `jar`, `war`, `windows`, `linux`, `osx`
- Docker: Image moved to https://ghcr.io/validator/validator
- NPMs now released to GitHub Packages, in addition to npmjs.com

# 20.6.30
30 June 2020
Expand Down
75 changes: 38 additions & 37 deletions README.md
Expand Up @@ -46,31 +46,32 @@ to have any version of Java already installed at all.

You can [get the latest release][16] or run [`docker run -it --rm -p 8888:8888
ghcr.io/validator/validator:latest`][17], [`npm install vnu-jar`][18],
[`brew install vnu`][19], or [`pip install html5validator`][20] and see the
[`npm install --registry=https://npm.pkg.github.com @validator/vnu-jar`][19],
[`brew install vnu`][20], or [`pip install html5validator`][21] and see the
**Usage** and **Web-based checking** sections below. Or automate your document
checking with a frontend such as:

[16]: https://github.com/validator/validator/releases/latest
[17]: https://github.com/validator/validator/pkgs/container/validator
[18]: https://www.npmjs.com/package/vnu-jar
[19]: https://libraries.io/homebrew/vnu
[19]: https://github.com/validator/validator/packages/892707
[20]: https://libraries.io/homebrew/vnu
[21]: https://github.com/svenkreiss/html5validator

[20]: https://github.com/svenkreiss/html5validator
* [Grunt plugin for HTML validation][22] or [Gulp plugin for HTML
validation][23] or [Maven plugin for HTML validation][24]

* [Grunt plugin for HTML validation][21] or [Gulp plugin for HTML
validation][22] or [Maven plugin for HTML validation][23]

* [html5validator `pip` package][24] (for integration in Travis CI, CircleCI,
* [html5validator `pip` package][25] (for integration in Travis CI, CircleCI,
CodeShip, Jekyll, Pelican, etc.)

* [LMVTFY: Let Me Validate That For You][25] (auto-check JSFiddle/JSBin, etc.,
* [LMVTFY: Let Me Validate That For You][26] (auto-check JSFiddle/JSBin, etc.,
links in GitHub issue comments)

[21]: https://github.com/validator/grunt-html
[22]: https://github.com/validator/gulp-html
[23]: https://github.com/validator/maven-plugin
[24]: https://github.com/svenkreiss/html5validator
[25]: https://github.com/cvrebert/lmvtfy/
[22]: https://github.com/validator/grunt-html
[23]: https://github.com/validator/gulp-html
[24]: https://github.com/validator/maven-plugin
[25]: https://github.com/svenkreiss/html5validator
[26]: https://github.com/cvrebert/lmvtfy/

## Usage

Expand All @@ -91,10 +92,10 @@ the following options:
--skip-non-svg --also-check-svg --html --skip-non-html
--format gnu|xml|json|text --help --verbose --version

The [Options][26] section below provides details on each option, and the rest of
The [Options][27] section below provides details on each option, and the rest of
this section provides some specific examples.

[26]: https://validator.github.io/validator/#options
[27]: https://validator.github.io/validator/#options

**Note:** Throughout these examples, replace `~/vnu.jar` with the actual path to
that jar file on your system, and replace `vnu-runtime-image/bin/vnu` and
Expand Down Expand Up @@ -344,13 +345,13 @@ provides the following options:
## Web-based checking

The Nu Html Checker — along with being usable as [a standalone command-line
client][27] — can be run as an HTTP service, similar to
[validator.w3.org/nu][28], for browser-based checking of HTML documents, CSS
client][28] — can be run as an HTTP service, similar to
[validator.w3.org/nu][29], for browser-based checking of HTML documents, CSS
stylesheets, and SVG images over the Web. To that end, the checker is released
as several separate packages:

[27]: https://validator.github.io/validator/#usage
[28]: https://validator.w3.org/nu/
[28]: https://validator.github.io/validator/#usage
[29]: https://validator.w3.org/nu/

* Linux, Windows, and macOS binaries for deploying the checker as a simple
self-contained service on any system
Expand All @@ -368,10 +369,10 @@ instance of the checker HTTP service — for fast command-line checking — or t
any remote instance of the checker HTTP service running anywhere on the Web.

The [latest releases of the Linux, Windows, and macOS binaries and vnu.jar and
vnu.war packages][29] are available from the `validator` project at github. The
vnu.war packages][30] are available from the `validator` project at github. The
following are detailed instructions on using them.

[29]: https://github.com/validator/validator/releases/latest
[30]: https://github.com/validator/validator/releases/latest

**Note:** Throughout these instructions, replace `~/vnu.jar` with the actual
path to that jar file on your system, and replace `vnu-runtime-image/bin/java`
Expand All @@ -391,10 +392,10 @@ a new terminal window and invoke the checker like this:

vnu-runtime-image\bin\java.exe nu.validator.servlet.Main 8888

Then open [http://0.0.0.0:8888][30] in a browser. (To listen on a different
Then open [http://0.0.0.0:8888][31] in a browser. (To listen on a different
port, replace `8888` with the port number.)

[30]: http://0.0.0.0:8888
[31]: http://0.0.0.0:8888

**Warning:** Future checker releases will bind by default to the address
`127.0.0.1`. Your checker deployment might become unreachable unless you use the
Expand All @@ -413,14 +414,14 @@ different address:
-Dnu.validator.servlet.bind-address=128.30.52.73 \
nu.validator.servlet.Main 8888

When you open [http://0.0.0.0:8888][31] (or whatever URL corresponds to the
When you open [http://0.0.0.0:8888][32] (or whatever URL corresponds to the
`nu.validator.servlet.bind-address` value you’re using), you’ll see a form
similar to [validator.w3.org/nu][32] that allows you to enter the URL of an HTML
similar to [validator.w3.org/nu][33] that allows you to enter the URL of an HTML
document, CSS stylesheet, or SVG image, and have the results of checking that
resource displayed in the browser.

[31]: http://0.0.0.0:8888
[32]: https://validator.w3.org/nu/
[32]: http://0.0.0.0:8888
[33]: https://validator.w3.org/nu/

**Note:** If you get a `StackOverflowError` error when using the checker, try
adjusting the thread stack size by providing the `-Xss` option to java:
Expand All @@ -434,11 +435,11 @@ adjusting the thread stack size by providing the `-Xss` option to java:
To run the checker inside of an existing servlet container such as Apache Tomcat
you will need to deploy the `vnu.war` file to that server following its
documentation. For example, on Apache Tomcat you could do this using the
[Manager][33] application or simply by copying the file to the `webapps`
[Manager][34] application or simply by copying the file to the `webapps`
directory (since that is the default `appBase` setting). Typically you would see
a message similar to the following in the `catalina.out` log file.

[33]: https://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html
[34]: https://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html

May 7, 2014 4:42:04 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/vnu.war
Expand All @@ -447,9 +448,9 @@ Assuming your servlet container is configured to receive HTTP requests sent to
`localhost` on port `80` and the context root of this application is `vnu`
(often the default behavior is to use the WAR file's filename as the context
root unless one is explicitly specified) you should be able to access the
application by connecting to [http://localhost/vnu/][34].
application by connecting to [http://localhost/vnu/][35].

[34]: http://localhost/vnu/
[35]: http://localhost/vnu/

**Note:** You may want to customize the `/WEB-INF/web.xml` file inside the WAR
file (you can use any ZIP-handling program) to modify the servlet filter
Expand Down Expand Up @@ -485,10 +486,10 @@ To check documents locally using the packaged HTTP client, do this:
vnu-runtime-image/bin/java nu.validator.client.HttpClient FILE.html...

To send documents to an instance of the checker on the Web, such as
[html5.validator.nu/][35], use the nu.validator.client.host and
[html5.validator.nu/][36], use the nu.validator.client.host and
nu.validator.client.port options, like this:

[35]: https://html5.validator.nu/
[36]: https://html5.validator.nu/

java -cp ~/vnu.jar -Dnu.validator.client.port=80 \
-Dnu.validator.client.host=html5.validator.nu \
Expand Down Expand Up @@ -522,9 +523,9 @@ ones by setting the value of the `nu.validator.client.level` system property to

Most of the properties listed below map to the common input parameters for the
checker service, as documented at
[github.com/validator/validator/wiki/Service-»-Common-params][36].
[github.com/validator/validator/wiki/Service-»-Common-params][37].

[36]: https://github.com/validator/validator/wiki/Service-%C2%BB-Common-params
[37]: https://github.com/validator/validator/wiki/Service-%C2%BB-Common-params

#### nu.validator.client.host

Expand Down Expand Up @@ -628,9 +629,9 @@ checker service, as documented at
## Pulling the Docker image

You can pull the checker Docker image from
[https://ghcr.io/validator/validator][37] in the GitHub container registry.
[https://ghcr.io/validator/validator][38] in the GitHub container registry.

[37]: https://ghcr.io/validator/validator
[38]: https://ghcr.io/validator/validator

To pull and run the latest version of the checker:

Expand Down
83 changes: 48 additions & 35 deletions build/build.py
Expand Up @@ -24,6 +24,7 @@

import os
import shutil
import json
try:
from urllib.request import urlopen
from urllib.error import URLError, HTTPError
Expand Down Expand Up @@ -1156,39 +1157,42 @@ def createOrUpdateGithubData(self):
args.append(os.path.join(buildRoot, "WHATSNEW.md"))
runCmd([ghRelCmd, 'edit', '-p'] + args)

def createPackageJson(self, packageJson, packageJsonCopy):
shutil.move(packageJson, packageJsonCopy)
f = open(packageJson, 'w')
with open(packageJsonCopy, 'r') as original:
for line in original:
if line.find(' "version":') != -1:
f.write(' "version": "%s",\n' % validatorVersion)
else:
f.write(line)
f.close
def createPackageJson(self, packageJson):
with open(packageJson, 'r') as original:
copy = json.load(original)
copy['version'] = validatorVersion
with open(packageJson, 'w') as f:
json.dump(copy, f)

def createGitHubPackageJson(self, packageJson):
with open(packageJson, 'r') as original:
copy = json.load(original)
copy['name'] = "@validator/vnu-jar"
copy['version'] = validatorVersion
copy['publishConfig'] = {"registry": "https://npm.pkg.github.com"}
with open(packageJson, 'w') as f:
json.dump(copy, f)

def createNpmReadme(self, readMe, readMeCopy):
splitAt = "see the **Pulling from Docker Hub** section below"
shutil.move(readMe, readMeCopy)
splitAt = "see **Pulling the Docker image** below"
npmFragment = os.path.join(buildRoot, "npm.md")
npmReadme = open(readMe, 'w')
with open(readMeCopy, 'r') as original:
skip = False
for line in original:
if line.find(splitAt) != -1:
skip = True
with open(npmFragment, 'r') as fragment:
for line in fragment:
npmReadme.write(line)
elif line.find("## Usage") != -1:
skip = False
npmReadme.write(line)
elif line.find("## Web-based checking") != -1:
skip = True
elif skip:
continue
else:
npmReadme.write(line)
skip = False
for line in readMeCopy.splitlines():
if line.find(splitAt) != -1:
skip = True
with open(npmFragment, 'r') as fragment:
for line in fragment:
npmReadme.write(line)
elif line.find("## Usage") != -1:
skip = False
npmReadme.write(line)
elif line.find("## Web-based checking") != -1:
skip = True
elif skip:
continue
else:
npmReadme.write(line + '\n')
npmReadme.close()

def removeExtras(self, whichDir):
Expand Down Expand Up @@ -1285,17 +1289,26 @@ def uploadNpm(self, tag=None):
removeIfExists(os.path.join(buildRoot, "README.md~"))
removeIfExists(os.path.join(buildRoot, "CHANGELOG.md~"))
readMe = os.path.join(buildRoot, "README.md")
readMeCopy = readMe + ".GOOD"
packageJson = os.path.join(buildRoot, "package.json")
packageJsonCopy = packageJson + ".GOOD"
with open(readMe, 'r') as f:
readMeCopy = f.read()
self.createNpmReadme(readMe, readMeCopy)
self.createPackageJson(packageJson, packageJsonCopy)
packageJson = os.path.join(buildRoot, "package.json")
with open(packageJson, 'r') as f:
packageJsonCopy = f.read()
self.createPackageJson(packageJson)
if tag:
runCmd([npmCmd, 'publish', '--tag', tag])
else:
runCmd([npmCmd, 'publish'])
self.createGitHubPackageJson(packageJson)
if tag:
runCmd([npmCmd, 'publish', '--tag', tag])
else:
runCmd([npmCmd, 'publish'])
shutil.move(readMeCopy, readMe)
shutil.move(packageJsonCopy, packageJson)
with open(readMe, 'w') as f:
f.write(readMeCopy)
with open(packageJson, 'w') as f:
f.write(packageJsonCopy)

def uploadToReleasesHost(self, jarOrWar, isNightly=False):
whichDir = distDir
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -159,7 +159,7 @@ <h1>The Nu Html Checker (v.Nu) <a href="https://matrix.to/#/#validator_validator
<b>Note:</b> The <var>vnu.jar</var> and <var>vnu.war</var> files require you to have Java 8 or above installed. The pre-compiled Linux, Windows, and macOS binaries don’t require you to have any version of Java already installed at all.

<p>
You can <a href="https://github.com/validator/validator/releases/latest">get the latest release</a> or run <a href="https://github.com/validator/validator/pkgs/container/validator"><code>docker run -it --rm -p 8888:8888 ghcr.io/validator/validator:latest</code></a>, <a href="https://www.npmjs.com/package/vnu-jar"><code>npm install vnu-jar</code></a>, <a href="https://libraries.io/homebrew/vnu"><code>brew install vnu</code></a>, or <a href="https://github.com/svenkreiss/html5validator"><code>pip install html5validator</code></a> and see the <a href="#usage"><b>Usage</b></a> and <a href="#web-based-checking"><b>Web-based checking</b></a> sections below. Or automate your document checking with a frontend such as:
You can <a href="https://github.com/validator/validator/releases/latest">get the latest release</a> or run <a href="https://github.com/validator/validator/pkgs/container/validator"><code>docker run -it --rm -p 8888:8888 ghcr.io/validator/validator:latest</code></a>, <a href="https://www.npmjs.com/package/vnu-jar"><code>npm install vnu-jar</code></a>, <a href="https://github.com/validator/validator/packages/892707"><code>npm install --registry=https://npm.pkg.github.com @validator/vnu-jar</code></a>, <a href="https://libraries.io/homebrew/vnu"><code>brew install vnu</code></a>, or <a href="https://github.com/svenkreiss/html5validator"><code>pip install html5validator</code></a> and see the <a href="#usage"><b>Usage</b></a> and <a href="#web-based-checking"><b>Web-based checking</b></a> sections below. Or automate your document checking with a frontend such as:
<ul>
<li>
<a href="https://github.com/validator/grunt-html">Grunt plugin for HTML validation</a>
Expand Down

0 comments on commit 4c45ffc

Please sign in to comment.