ソースを参照

Fix build for web extensions and site

pull/544/head
Guillaume Vincent 4年前
コミット
0a8098a646
7個のファイルの変更244行の追加162行の削除
  1. +114
    -0
      bin/build_web_extensions
  2. +112
    -0
      bin/build_web_site
  3. +3
    -2
      bin/deploy_web_extensions
  4. +0
    -139
      bin/release
  5. +1
    -1
      packages/lesspass-site/package.json
  6. +14
    -9
      packages/lesspass-web-extension/amo.md
  7. +0
    -11
      packages/lesspass-web-extension/gulpfile.js

+ 114
- 0
bin/build_web_extensions ファイルの表示

@@ -0,0 +1,114 @@
#!/usr/bin/env bash

RED='\033[0;31m'
NOCOLOR='\033[0m'

function print_error {
echo -e "${RED}$1${NOCOLOR}"
}

function check_current_directory_is_root {
if [ ! -f README.md ]; then
print_error "You seems to be in the wrong directory"
print_error "Execute this script from the root of lesspass with ./bin/${0##*/}"
exit 1
fi
}

function check_repository_is_clean {
git remote update
git add .
git status
git diff-index --quiet HEAD
if [ $? == 1 ]
then
print_error "Git repository not clean. Aborting."
exit 1
fi
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]
then
print_error "Git branch diverged. Aborting."
exit 1
fi
}

function check_branch_is_master {
BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
if [ $BRANCH_NAME != "master" ]
then
print_error "Current branch is not master. Aborting."
exit 1
fi
}

function check_bump_type_is_defined {
bump_type="${1}"
if [ "${bump_type}" != "major" ] && [ "${bump_type}" != "minor" ] && [ "${bump_type}" != "patch" ]
then
print_error "Error: No bump type specified (major, minor, patch). Aborting."
exit 1
fi
}

set +o errexit

bump_type="${1:-}"
check_bump_type_is_defined ${bump_type}
check_branch_is_master
check_current_directory_is_root
check_repository_is_clean

set -o errexit
set -o pipefail
set -o nounset

function increment_version {
IFS='.' read -a versions <<< "${1}"

major=${versions[0]}
minor=${versions[1]}
patch=${versions[2]}

case "${2}" in
"major")
major=$((major + 1))
minor=0
patch=0
;;
"minor")
minor=$((minor + 1))
patch=0
;;
"patch")
patch=$((patch + 1))
;;
esac
new_version="$major.$minor.$patch"
echo ${new_version}
}

function build {
yarn install
rm -rf packages/lesspass-web-extension/extension/dist
mkdir packages/lesspass-web-extension/extension/dist
cp -r node_modules/lesspass-pure/dist/. packages/lesspass-web-extension/extension/dist/
}


function commit_and_push {
git add .
git commit --message="Auto build for lesspass-web-extension"
#git push
}

current_version=$( grep -Po '(?<="version": ")[^"]*' packages/lesspass-web-extension/package.json )
echo "Current lesspass-web-extension version is ${current_version}"
new_version=$( increment_version ${current_version} ${bump_type} )
echo "New lesspass-web-extension version is ${new_version}"
latest_lesspass_pure_version=$( yarn info -s lesspass-pure version )
echo "Latest lesspass-pure version is ${latest_lesspass_pure_version}"
sed -i -E "s/\"lesspass-pure\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"lesspass-pure\": \"${latest_lesspass_pure_version}\"/g" packages/lesspass-web-extension/package.json
sed -i -E "s/\"version\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"version\": \"${new_version}\"/g" packages/lesspass-web-extension/package.json
build
commit_and_push

+ 112
- 0
bin/build_web_site ファイルの表示

@@ -0,0 +1,112 @@
#!/usr/bin/env bash

RED='\033[0;31m'
NOCOLOR='\033[0m'

function print_error {
echo -e "${RED}$1${NOCOLOR}"
}

function check_current_directory_is_root {
if [ ! -f README.md ]; then
print_error "You seems to be in the wrong directory"
print_error "Execute this script from the root of lesspass with ./bin/${0##*/}"
exit 1
fi
}

function check_repository_is_clean {
git remote update
git add .
git status
git diff-index --quiet HEAD
if [ $? == 1 ]
then
print_error "Git repository not clean. Aborting."
exit 1
fi
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]
then
print_error "Git branch diverged. Aborting."
exit 1
fi
}

function check_branch_is_master {
BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
if [ $BRANCH_NAME != "master" ]
then
print_error "Current branch is not master. Aborting."
exit 1
fi
}

function check_bump_type_is_defined {
bump_type="${1}"
if [ "${bump_type}" != "major" ] && [ "${bump_type}" != "minor" ] && [ "${bump_type}" != "patch" ]
then
print_error "Error: No bump type specified (major, minor, patch). Aborting."
exit 1
fi
}

set +o errexit

bump_type="${1:-}"
check_bump_type_is_defined ${bump_type}
check_branch_is_master
check_current_directory_is_root
check_repository_is_clean

set -o errexit
set -o pipefail
set -o nounset

function increment_version {
IFS='.' read -a versions <<< "${1}"

major=${versions[0]}
minor=${versions[1]}
patch=${versions[2]}

case "${2}" in
"major")
major=$((major + 1))
minor=0
patch=0
;;
"minor")
minor=$((minor + 1))
patch=0
;;
"patch")
patch=$((patch + 1))
;;
esac
new_version="$major.$minor.$patch"
echo ${new_version}
}

function build {
yarn install
yarn workspace lesspass-site run build
}


function commit_and_push {
git add .
git commit --message="Auto build for lesspass-site"
#git push
}

current_version=$( grep -Po '(?<="version": ")[^"]*' packages/lesspass-site/package.json )
echo "Current lesspass-site version is ${current_version}"
new_version=$( increment_version ${current_version} ${bump_type} )
echo "New lesspass-site version is ${new_version}"
latest_lesspass_pure_version=$( yarn info -s lesspass-pure version )
echo "Latest lesspass-pure version is ${latest_lesspass_pure_version}"
sed -i -E "s/\"lesspass-pure\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"lesspass-pure\": \"${latest_lesspass_pure_version}\"/g" packages/lesspass-site/package.json
sed -i -E "s/\"version\": \"([0-9]+)\.([0-9]+)\.([0-9]+)\"/\"version\": \"${new_version}\"/g" packages/lesspass-site/package.json
build
commit_and_push

+ 3
- 2
bin/deploy_web_extensions ファイルの表示

@@ -18,8 +18,9 @@ set -o nounset
function release_web_extensions {
yarn install
yarn workspace lesspass-web-extension run release
VERSION=$(grep -Po '(?<="version": ")[^"]*' package.json)
echo "Download sources on https://github.com/lesspass/lesspass/releases/tag/${VERSION}"
commit=$( git rev-parse HEAD )
wget http://github.com/lesspass/lesspass/archive/${commit}.zip
echo "Sources saved in ${commit}.zip"
echo "Upload them on https://addons.mozilla.org/en-US/developers/"
}


+ 0
- 139
bin/release ファイルの表示

@@ -1,139 +0,0 @@
#!/usr/bin/env bash

RED='\033[0;31m'
NOCOLOR='\033[0m'

function print_error {
echo -e "${RED}$1${NOCOLOR}"
}

function check_current_directory_is_root {
if [ ! -f README.md ]; then
print_error "You seems to be in the wrong directory"
print_error "Execute this script from the root of lesspass with ./bin/${0##*/}"
exit 1
fi
}

function check_repository_is_clean {
git remote update
git add .
git status
git diff-index --quiet HEAD
if [ $? == 1 ]
then
print_error "Git repository not clean. Aborting."
exit 1
fi
if [ $(git rev-parse HEAD) != $(git rev-parse @{u}) ]
then
print_error "Git branch diverged. Aborting."
exit 1
fi
}

function check_branch_is_master {
BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2)
if [ $BRANCH_NAME != "master" ]
then
print_error "Current branch is not master. Aborting."
exit 1
fi
}

function check_bump_type_is_defined {
bump_type="${1}"
if [ "${bump_type}" != "major" ] && [ "${bump_type}" != "minor" ] && [ "${bump_type}" != "patch" ]
then
print_error "Error: No bump type specified (major, minor, patch). Aborting."
exit 1
fi
}

set +o errexit

check_branch_is_master
bump_type="${1:-}"
check_bump_type_is_defined ${bump_type}
check_current_directory_is_root
check_repository_is_clean

set -o errexit
set -o pipefail
set -o nounset

function increment_version {
IFS='.' read -a versions <<< "${1}"

major=${versions[0]}
minor=${versions[1]}
patch=${versions[2]}

case "${2}" in
"major")
major=$((major + 1))
minor=0
patch=0
;;
"minor")
minor=$((minor + 1))
patch=0
;;
"patch")
patch=$((patch + 1))
;;
esac
new_version="$major.$minor.$patch"
echo ${new_version}
}

function replace_versions_in_files {
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" package.json
sed -i "s/__version__ = \"${1}\"/__version__ = \"${2}\"/g" cli/lesspass/version.py
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" mobile/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" mobile/src/version.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass/package.json
sed -i "s/\"lesspass-entropy\": \"${1}\"/\"lesspass-entropy\": \"${2}\"/g" packages/lesspass/package.json
sed -i "s/\"lesspass-fingerprint\": \"${1}\"/\"lesspass-fingerprint\": \"${2}\"/g" packages/lesspass/package.json
sed -i "s/\"lesspass-render-password\": \"${1}\"/\"lesspass-render-password\": \"${2}\"/g" packages/lesspass/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-crypto/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-entropy/package.json
sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-entropy/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
sed -i "s/\"lesspass-crypto\": \"${1}\"/\"lesspass-crypto\": \"${2}\"/g" packages/lesspass-fingerprint/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-pure/package.json
sed -i "s/\"lesspass\": \"${1}\"/\"lesspass\": \"${2}\"/g" packages/lesspass-pure/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-render-password/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-site/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/package.json
sed -i "s/\"lesspass-pure\": \"${1}\"/\"lesspass-pure\": \"${2}\"/g" packages/lesspass-web-extension/package.json
sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" packages/lesspass-web-extension/extension/manifest.json
}

function build_web_extensions {
yarn install
yarn workspace lesspass-pure run build
rm -rf packages/lesspass-web-extension/extension/dist
mkdir packages/lesspass-web-extension/extension/dist
cp -r packages/lesspass-pure/dist/. packages/lesspass-web-extension/extension/dist/
}

function build_mobile_app {
pushd mobile/android/
./gradlew bundleRelease
popd
}

function tag {
git add .
git commit --message="LessPass version ${1}"
git tag "${1}"
}

current_version=$( grep -Po '(?<="version": ")[^"]*' package.json )
new_version=$( increment_version ${current_version} ${bump_type} )
replace_versions_in_files ${current_version} ${new_version}
build_web_extensions
build_mobile_app
tag ${new_version}

+ 1
- 1
packages/lesspass-site/package.json ファイルの表示

@@ -12,7 +12,7 @@
},
"dependencies": {
"express": "^4.17.1",
"lesspass-pure": "latest"
"lesspass-pure": "9.1.9"
},
"devDependencies": {
"favicons": "^5.4.1",


+ 14
- 9
packages/lesspass-web-extension/amo.md ファイルの表示

@@ -2,19 +2,24 @@

## Verify the web extension

The web extension is just a wrapper around lesspass-pure on npm
The web extension is just a wrapper around lesspass-pure on npm.
Source file correspond to the zip downloaded on http://github.com/lesspass/lesspass/archive/${sha256}.zip.
{sha256} is the git sha256 use when build was done.

node --version: v10.15.0
yarn --version: v1.16.0
## requirements

## Rebuild the web extension with sources
To rebuild the web extension, you need node, yarn and md5sum to check the md5 sum of the files

untar src and install dependencies
Tested with:

yarn install
./bin/build_web_extensions
cd packages/lesspass-web-extension/build
find . -type f -exec md5sum {} \;
* node version 12.16.3
* yarn version 1.22.4
* md5sum (GNU coreutils) version 8.32

## unzip source {sha256}.zip

unzip {sha256}.zip -d /tmp
cd /tmp/lesspass-{sha256}

## Reproduce lesspass.min.js and dist folder with sources



+ 0
- 11
packages/lesspass-web-extension/gulpfile.js ファイルの表示

@@ -1,11 +0,0 @@
const { src, dest, parallel } = require("gulp");

function js() {
return src([
"node_modules/lesspass-pure/dist/**/*",
"extension/popup.js"
]).pipe(dest("extension/dist/"));
}

exports.js = js;
exports.default = parallel(js);

読み込み中…
キャンセル
保存