Skip to content

Commit

Permalink
Write sha256 sums to file on package and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Mar 7, 2018
1 parent 7c7f32e commit 079cec0
Show file tree
Hide file tree
Showing 8 changed files with 2,280 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ deploy:
file_glob: true
file:
- build/binaries/BitShares*
- build/shasums_$TRAVIS_JOB_NUMBER.txt
- build/release-checksums-*
skip_cleanup: true
draft: true
on:
Expand Down
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ before_package:
echo Before package
after_test:
- 7z a build\html5_history_dist_%APPVEYOR_REPO_TAG_NAME%.zip %APPVEYOR_BUILD_FOLDER%\build\dist -r
- 7z a build\hash_history_dist_%APPVEYOR_REPO_TAG_NAME%.zip %APPVEYOR_BUILD_FOLDER%\build\hash-history_'' -r
- 7z a build\hash_history_dist_%APPVEYOR_REPO_TAG_NAME%.zip %APPVEYOR_BUILD_FOLDER%\build\hash-history -r
- node ./write_digest.js
test_script:
- npm run package
- npm run build
Expand All @@ -27,6 +28,8 @@ artifacts:
name: html5_history_dist
- path: build\hash_history_dist_*.zip
name: hash_history_dist
- path: build\release-checksums-*
name: release-checksums-windows
deploy:
provider: GitHub
release: $(APPVEYOR_REPO_TAG_NAME)
Expand Down
4 changes: 1 addition & 3 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
cd $TRAVIS_BUILD_DIR
unamestr=`uname`
if [[ "$unamestr" == 'Linux' && -n $TRAVIS_TAG ]]
if [ "$unamestr" == 'Linux' ]
then
# npm run build-github
npm run build-hash
fi
if [ $TRAVIS_TAG ]
then
npm run-script package
# shasum -a256 $TRAVIS_BUILD_DIR/build/binaries/* > $TRAVIS_BUILD_DIR/shasums_$TRAVIS_JOB_NUMBER.txt
fi
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ then
git checkout gh-pages
rm -rf ./*
git checkout ./CNAME
cp -Rv $TRAVIS_BUILD_DIR/build/hash-history_/* .
cp -Rv $TRAVIS_BUILD_DIR/build/hash-history/* .
git add -A
git commit -a -m "Update wallet by Travis: v$TRAVIS_TAG"
git push
Expand Down
2,125 changes: 2,125 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"package-no-ugly": "build -p never",
"package-deb": "npm run prepackage && build -p never --linux deb",
"package-win": "npm run prepackage && build -p never --windows",
"package-mac": "npm run prepackage && build -p never --mac dmg"
"package-mac": "npm run prepackage && build -p never --mac dmg",
"postpackage": "node write_digest.js"
},
"jest": {
"scriptPreprocessor": "<rootDir>/__tests__/jest-preprocessor.js",
Expand Down Expand Up @@ -201,6 +202,7 @@
"express-history-api-fallback": "^2.1.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.8.4",
"fs-jetpack": "^1.3.0",
"git-rev-sync": "^1.9.1",
"html-loader": "^0.4.4",
"husky": "^0.14.3",
Expand Down
142 changes: 95 additions & 47 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(env) {
}
];

var scssLoaders = [
var scssLoaders = [
{
loader: "style-loader"
},
Expand Down Expand Up @@ -59,15 +59,23 @@ module.exports = function(env) {
__ELECTRON__: !!env.electron,
__HASH_HISTORY__: !!env.hash,
__BASE_URL__: JSON.stringify(baseUrl),
__UI_API__: JSON.stringify(env.apiUrl || "https://ui.bitshares.eu/api"),
__UI_API__: JSON.stringify(
env.apiUrl || "https://ui.bitshares.eu/api"
),
__TESTNET__: !!env.testnet,
__DEPRECATED__: !!env.deprecated
})
];

if (env.prod) {
// PROD OUTPUT PATH
let outputDir = env.electron ? "electron" : env.hash ? `hash-history_${baseUrl.replace("/", "")}` : "dist";
let outputDir = env.electron
? "electron"
: env.hash
? !baseUrl
? "hash-history"
: `hash-history_${baseUrl.replace("/", "")}`
: "dist";
outputPath = path.join(root_dir, "build", outputDir);

// DIRECTORY CLEANER
Expand All @@ -77,60 +85,81 @@ module.exports = function(env) {
const extractCSS = new ExtractTextPlugin("app.css");
cssLoaders = ExtractTextPlugin.extract({
fallback: "style-loader",
use: [{loader: "css-loader"}, {loader: "postcss-loader", options: {
plugins: [require("autoprefixer")]
}}]}
);
scssLoaders = ExtractTextPlugin.extract({fallback: "style-loader",
use: [{loader: "css-loader"}, {loader: "postcss-loader", options: {
plugins: [require("autoprefixer")]
}}, {loader: "sass-loader", options: {outputStyle: "expanded"}}]}
);
use: [
{loader: "css-loader"},
{
loader: "postcss-loader",
options: {
plugins: [require("autoprefixer")]
}
}
]
});
scssLoaders = ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{loader: "css-loader"},
{
loader: "postcss-loader",
options: {
plugins: [require("autoprefixer")]
}
},
{loader: "sass-loader", options: {outputStyle: "expanded"}}
]
});

// PROD PLUGINS
plugins.push(new Clean(cleanDirectories, {root: root_dir}));
plugins.push(new webpack.DefinePlugin({
"process.env": {NODE_ENV: JSON.stringify("production")},
__DEV__: false
}));
plugins.push(
new webpack.DefinePlugin({
"process.env": {NODE_ENV: JSON.stringify("production")},
__DEV__: false
})
);
plugins.push(extractCSS);
plugins.push(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}));
plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
);
plugins.push(new webpack.optimize.ModuleConcatenationPlugin());
if (!env.noUgly) {

plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: true
},
output: {
screw_ie8: true
}
}));
plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: true
},
output: {
screw_ie8: true
}
})
);
}
} else {
// plugins.push(new webpack.optimize.OccurenceOrderPlugin());
plugins.push(new webpack.DefinePlugin({
"process.env": {NODE_ENV: JSON.stringify("development")},
__DEV__: true
}));
plugins.push(
new webpack.DefinePlugin({
"process.env": {NODE_ENV: JSON.stringify("development")},
__DEV__: true
})
);
plugins.push(new webpack.HotModuleReplacementPlugin());
plugins.push(new webpack.NoEmitOnErrorsPlugin());
}

var config = {
entry: {
// vendor: ["react", "react-dom", "highcharts/highstock", "bitsharesjs", "lodash"],
app: env.prod ?
path.resolve(root_dir, "app/Main.js") :
[
"react-hot-loader/patch",
"webpack-hot-middleware/client",
path.resolve(root_dir, "app/Main-dev.js")
]
app: env.prod
? path.resolve(root_dir, "app/Main.js")
: [
"react-hot-loader/patch",
"webpack-hot-middleware/client",
path.resolve(root_dir, "app/Main-dev.js")
]
},
output: {
publicPath: env.prod ? "" : "/",
Expand All @@ -144,7 +173,13 @@ module.exports = function(env) {
rules: [
{
test: /\.jsx$/,
include: [path.join(root_dir, "app"), path.join(root_dir, "node_modules/react-foundation-apps")],
include: [
path.join(root_dir, "app"),
path.join(
root_dir,
"node_modules/react-foundation-apps"
)
],
use: [
{
loader: "babel-loader",
Expand All @@ -161,14 +196,18 @@ module.exports = function(env) {
options: {compact: false, cacheDirectory: true}
},
{
test: /\.json/, loader: "json-loader",
test: /\.json/,
loader: "json-loader",
exclude: [
path.resolve(root_dir, "app/lib/common"),
path.resolve(root_dir, "app/assets/locales")
]
},
{ test: /\.coffee$/, loader: "coffee-loader" },
{ test: /\.(coffee\.md|litcoffee)$/, loader: "coffee-loader?literate" },
{test: /\.coffee$/, loader: "coffee-loader"},
{
test: /\.(coffee\.md|litcoffee)$/,
loader: "coffee-loader?literate"
},
{
test: /\.css$/,
use: cssLoaders
Expand All @@ -179,7 +218,13 @@ module.exports = function(env) {
},
{
test: /\.png$/,
exclude:[path.resolve(root_dir, "app/assets/asset-symbols"), path.resolve(root_dir, "app/assets/language-dropdown/img")],
exclude: [
path.resolve(root_dir, "app/assets/asset-symbols"),
path.resolve(
root_dir,
"app/assets/language-dropdown/img"
)
],
use: [
{
loader: "url-loader",
Expand All @@ -202,7 +247,10 @@ module.exports = function(env) {
}
]
},
{ test: /.*\.svg$/, loaders: ["svg-inline-loader", "svgo-loader"] },
{
test: /.*\.svg$/,
loaders: ["svg-inline-loader", "svgo-loader"]
},
{
test: /\.md/,
use: [
Expand Down
50 changes: 50 additions & 0 deletions write_digest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
var crypto = require("crypto");
var fs = require("fs");
var os = require("os");
var path = require("path");
var packageJSON = require("./package.json");
var jetpack = require("fs-jetpack");
var releasesDir = jetpack.dir("./build");

console.log(`\nUI version ${packageJSON.version} sha256 sums:\n`);

var platform = os.platform();

var binaryPath = "build/binaries/";
var htmlPath = "build/";

var files = [];
var binaries = fs.readdirSync(binaryPath).filter(function(a) {
return a.indexOf(packageJSON.version) !== -1;
});
binaries.forEach(function(file) {
files.push({fullPath: path.resolve(binaryPath, file), fileName: file});
});
var htmlZipFiles = fs.readdirSync(htmlPath).filter(function(a) {
return a.indexOf(packageJSON.version) !== -1 && a.indexOf("zip") !== -1;
});
htmlZipFiles.forEach(function(file) {
files.push({fullPath: path.resolve(htmlPath, file), fileName: file});
});

if (!files.length) return;
releasesDir.remove(`release-checksums-${platform}`);
files.forEach(function(file) {
var sha256 = crypto.createHash("sha256");
var s = fs.ReadStream(file.fullPath);
s.on("data", function(d) {
sha256.update(d);
});

s.on("end", function() {
var d2 = sha256.digest("hex");

console.log(`__${file.fileName}__`);
console.log("`" + d2 + "`");

releasesDir.append(
`release-checksums-${platform}`,
`\n__${file.fileName}__` + "\n`" + d2 + "`"
);
});
});

0 comments on commit 079cec0

Please sign in to comment.