Skip to content

Commit 2cf778c

Browse files
authored
Include git ref in website download zip name (#2339)
1 parent 37a9246 commit 2cf778c

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

Gruntfile.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ module.exports = function (grunt) {
8989
const compileYear = grunt.template.today("UTC:yyyy"),
9090
compileTime = grunt.template.today("UTC:dd/mm/yyyy HH:MM:ss") + " UTC",
9191
pkg = grunt.file.readJSON("package.json"),
92+
version = process.env.GITHUB_SHA || `v${pkg.version}`,
93+
downloadZipFilename = `CyberChef_${version}.zip`,
9294
webpackConfig = require("./webpack.config.js"),
9395
BUILD_CONSTANTS = {
9496
COMPILE_YEAR: JSON.stringify(compileYear),
@@ -129,7 +131,9 @@ module.exports = function (grunt) {
129131
chunks: ["main"],
130132
compileYear: compileYear,
131133
compileTime: compileTime,
132-
version: pkg.version,
134+
version: version,
135+
latestReleaseVersion: pkg.version,
136+
downloadZipFilename: downloadZipFilename,
133137
minify: {
134138
removeComments: true,
135139
collapseWhitespace: true,
@@ -245,7 +249,7 @@ module.exports = function (grunt) {
245249
"!build/prod/index.html",
246250
"!build/prod/BundleAnalyzerReport.html",
247251
],
248-
dest: `build/prod/CyberChef_v${pkg.version}.zip`
252+
dest: `build/prod/${downloadZipFilename}`
249253
}
250254
},
251255
connect: {
@@ -333,12 +337,12 @@ module.exports = function (grunt) {
333337
switch (process.platform) {
334338
case "darwin":
335339
return chainCommands([
336-
`shasum -a 256 build/prod/CyberChef_v${pkg.version}.zip | awk '{print $1;}' > build/prod/sha256digest.txt`,
340+
`shasum -a 256 build/prod/${downloadZipFilename} | awk '{print $1;}' > build/prod/sha256digest.txt`,
337341
`sed -i '' -e "s/DOWNLOAD_HASH_PLACEHOLDER/$(cat build/prod/sha256digest.txt)/" build/prod/index.html`
338342
]);
339343
default:
340344
return chainCommands([
341-
`sha256sum build/prod/CyberChef_v${pkg.version}.zip | awk '{print $1;}' > build/prod/sha256digest.txt`,
345+
`sha256sum build/prod/${downloadZipFilename} | awk '{print $1;}' > build/prod/sha256digest.txt`,
342346
`sed -i -e "s/DOWNLOAD_HASH_PLACEHOLDER/$(cat build/prod/sha256digest.txt)/" build/prod/index.html`
343347
]);
344348
}

src/web/html/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,15 +868,15 @@ <h5 class="modal-title">Download CyberChef</h5>
868868
Be aware that the standalone version will never update itself, meaning it will not receive bug fixes or new features until you re-download newer versions manually.
869869
</p>
870870

871-
<h6>CyberChef v<%= htmlWebpackPlugin.options.version %></h6>
871+
<h6>CyberChef <%= htmlWebpackPlugin.options.version %></h6>
872872
<ul>
873873
<li>Build time: <%= htmlWebpackPlugin.options.compileTime %></li>
874-
<li>The changelog for this version can be viewed <a href="https://github.com/gchq/CyberChef/blob/v<%= htmlWebpackPlugin.options.version %>/CHANGELOG.md">here</a></li>
874+
<li>The changelog for this version can be viewed <a href="https://github.com/gchq/CyberChef/blob/v<%= htmlWebpackPlugin.options.latestReleaseVersion %>/CHANGELOG.md">here</a></li>
875875
<li>&copy; Crown Copyright 2016-<%= htmlWebpackPlugin.options.compileYear %></li>
876876
<li>Released under the Apache Licence, Version 2.0</li>
877877
<li>SHA256 hash: DOWNLOAD_HASH_PLACEHOLDER</li>
878878
</ul>
879-
<a href="CyberChef_v<%= htmlWebpackPlugin.options.version %>.zip" download class="btn btn-outline-primary">Download ZIP file</a>
879+
<a href="<%= htmlWebpackPlugin.options.downloadZipFilename %>" download class="btn btn-outline-primary">Download ZIP file</a>
880880
</div>
881881
<div class="modal-footer">
882882
<button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>

0 commit comments

Comments
 (0)