diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 27a4704..fe651e4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,22 +12,20 @@ jobs: - uses: actions/checkout@v1 - name: deploy containers run: | - cd containers - ./deploy + ./bin/deploy_containers env: QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} - deploy-packages: + deploy-node-modules: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - name: deploy packages + - name: deploy node modules run: | - cd packages - ./deploy + ./bin/deploy_node_modules env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} deploy-cli: runs-on: ubuntu-latest @@ -38,12 +36,23 @@ jobs: with: python-version: '3.x' - name: deploy cli + run: | + ./bin/deploy_cli env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + deploy-web-extensions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: deploy web extensions run: | - cd cli - python -m pip install --upgrade pip - pip install setuptools wheel twine - python setup.py sdist bdist_wheel - twine upload dist/* + ./bin/deploy_web_extensions + env: + EXTENSION_ID: ${{ secrets.EXTENSION_ID }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + WEB_EXT_API_KEY: ${{ secrets.WEB_EXT_API_KEY }} + WEB_EXT_API_SECRET: ${{ secrets.WEB_EXT_API_SECRET }} diff --git a/bin/build_web_extensions b/bin/build_web_extensions deleted file mode 100755 index 08c91bd..0000000 --- a/bin/build_web_extensions +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o pipefail -set -o nounset - -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/ diff --git a/bin/deploy_cli b/bin/deploy_cli new file mode 100755 index 0000000..5acc892 --- /dev/null +++ b/bin/deploy_cli @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +function check_env_variables_are_setted { + if [ -z "${TWINE_USERNAME}" ] || [ -z "${TWINE_PASSWORD}" ]; then + echo "Need to set TWINE_USERNAME and TWINE_PASSWORD env variables to release cli" + exit 1 + fi +} + +set +o errexit + +check_env_variables_are_setted + +set -o errexit +set -o pipefail +set -o nounset + +function push_cli_on_pypi { + pushd cli + python -m pip install --upgrade pip + pip install setuptools wheel twine + python setup.py sdist bdist_wheel + twine upload dist/* + popd +} + +push_cli_on_pypi \ No newline at end of file diff --git a/bin/deploy_containers b/bin/deploy_containers new file mode 100755 index 0000000..1439a7f --- /dev/null +++ b/bin/deploy_containers @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +function check_env_variables_are_setted { + if [ -z "${QUAY_USERNAME}" ] || [ -z "${QUAY_PASSWORD}" ]; then + echo "Need to set QUAY_USERNAME and QUAY_PASSWORD env variables to release containers" + exit 1 + fi +} + +set +o errexit + +check_env_variables_are_setted + +set -o errexit +set -o pipefail +set -o nounset + +function build_and_push_container { + pushd containers + container=$1 + docker build --tag lesspass/${container} ./${container} + docker tag lesspass/${container} quay.io/lesspass/${container} + docker push quay.io/lesspass/${container} + popd +} + +function build_and_push_containers { + docker login --username="${QUAY_USERNAME}" --password="${QUAY_PASSWORD}" quay.io + build_and_push_container webserver + build_and_push_container backend + build_and_push_container frontend +} + +build_and_push_containers \ No newline at end of file diff --git a/bin/deploy_node_modules b/bin/deploy_node_modules new file mode 100755 index 0000000..2fdb18c --- /dev/null +++ b/bin/deploy_node_modules @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +function check_env_variables_are_setted { + if [ -z "${NPM_TOKEN}" ]; then + echo "Need to set NPM_TOKEN env variable to release node modules" + exit 1 + fi +} + +set +o errexit + +check_env_variables_are_setted + +set -o errexit +set -o pipefail +set -o nounset + +function push_packages_on_npm { + grep --fixed-strings --line-regexp --silent "//registry.npmjs.org/:_authToken=$NPM_TOKEN" ~/.npmrc + if [ $? == 1 ] + then + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc + fi + projects="lesspass lesspass-crypto lesspass-entropy lesspass-fingerprint lesspass-pure lesspass-render-password" + for project in ${projects} + do + pushd packages/${project} + yarn publish --new-version + popd + done +} + +push_packages_on_npm \ No newline at end of file diff --git a/bin/deploy_web_extensions b/bin/deploy_web_extensions new file mode 100755 index 0000000..5bc19cb --- /dev/null +++ b/bin/deploy_web_extensions @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +function check_env_variables_are_setted { + if [ -z "${EXTENSION_ID}" ] || [ -z "${CLIENT_ID}" ] || [ -z "${CLIENT_SECRET}" ] || [ -z "${REFRESH_TOKEN}" ] || [ -z "${WEB_EXT_API_KEY}" ] || [ -z "${WEB_EXT_API_SECRET}" ]; then + echo "Need to set EXTENSION_ID, CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN, WEB_EXT_API_KEY and WEB_EXT_API_SECRET env variables to release web extensions" + exit 1 + fi +} + +set +o errexit + +check_env_variables_are_setted + +set -o errexit +set -o pipefail +set -o nounset + +function release_web_extensions { + 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}" + echo "Upload them on https://addons.mozilla.org/en-US/developers/" +} + +release_web_extensions \ No newline at end of file diff --git a/bin/tag b/bin/release similarity index 59% rename from bin/tag rename to bin/release index ea19426..a079d26 100755 --- a/bin/tag +++ b/bin/release @@ -1,13 +1,57 @@ #!/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 +} + +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 -git diff-index --quiet HEAD -if [ $? == 1 ] -then - echo >&2 "Git repository not clean. Aborting." - exit 1 -fi +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 @@ -60,7 +104,20 @@ function replace_versions_in_files { 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 - sed -i "s/VERSION=\"${1}\"/VERSION=\"${2}\"/g" containers/deploy +} + +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 assembleRelease + popd } function tag { @@ -69,17 +126,9 @@ function tag { git tag "${1}" } -__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -__root="$(cd "$(dirname "${__dir}")" && pwd)" -pushd ${__root} -bump_type="${1:-}" -if [ "${bump_type}" == "major" ] || [ "${bump_type}" == "minor" ] || [ "${bump_type}" == "patch" ] -then - current_version=$(grep -Po '(?<="version": ")[^"]*' package.json) - new_version=$( increment_version ${current_version} ${bump_type} ) - replace_versions_in_files ${current_version} ${new_version} - tag ${new_version} -else - echo >&2 "Error: No bump type specified (major, minor, patch). Aborting." - exit 1 -fi \ No newline at end of file +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} diff --git a/bin/release_web_extensions b/bin/release_web_extensions deleted file mode 100755 index 04c7047..0000000 --- a/bin/release_web_extensions +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -set +o errexit - -function check_branch_is_master { - BRANCH_NAME=$(git branch | grep \* | cut -d ' ' -f2) - if [ $BRANCH_NAME != "master" ] - then - echo >&2 "Current branch is not master. Aborting." - exit 1 - fi -} - -function check_tag_is_present { - git describe --exact-match --tags - if [ $? != 0 ] - then - echo >&2 "Current revision is not tagged. Aborting." - exit 1 - fi -} - -function check_repository_is_clean { - git remote update - git status - git diff-index --quiet HEAD --; - if [ $? == 1 ] - then - echo >&2 "Git repository not clean. Aborting." - exit 1 - fi -} - -function check_env_variables_setted { - if [ -z "$EXTENSION_ID" ] || [ -z "$CLIENT_ID" ] || [ -z "$CLIENT_SECRET" ] || [ -z "$REFRESH_TOKEN" ] || [ -z "$WEB_EXT_API_KEY" ] || [ -z "$WEB_EXT_API_SECRET" ]; then - echo "Need to set EXTENSION_ID, CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN, WEB_EXT_API_KEY and WEB_EXT_API_SECRET env variables to release web extensions" - exit 1 - fi -} - -check_branch_is_master -check_tag_is_present -check_env_variables_setted -yarn workspace lesspass-web-extension run build -yarn workspace lesspass-pure run build -check_repository_is_clean - -set -o errexit -set -o pipefail -set -o nounset - -yarn workspace lesspass-web-extension run release -VERSION=$(grep -Po '(?<="version": ")[^"]*' package.json) -echo "See the new release on https://github.com/lesspass/lesspass/releases/tag/${VERSION}" diff --git a/containers/deploy b/containers/deploy deleted file mode 100755 index d2d780e..0000000 --- a/containers/deploy +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -e - -build_and_push () { - PROJECT=$1 - docker build --tag lesspass/${PROJECT} ./${PROJECT} - docker tag lesspass/${PROJECT} quay.io/lesspass/${PROJECT} - docker push quay.io/lesspass/${PROJECT} -} - -docker login --username="${QUAY_USERNAME}" --password="${QUAY_PASSWORD}" quay.io -build_and_push webserver -build_and_push backend -build_and_push frontend diff --git a/packages/deploy b/packages/deploy deleted file mode 100755 index 256b632..0000000 --- a/packages/deploy +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -set -e - -install_and_publish () { - PROJECT=$1 - pushd ${PROJECT} - yarn publish - popd -} - -projects="lesspass lesspass-crypto lesspass-entropy lesspass-fingerprint lesspass-pure lesspass-render-password" -for project in ${projects} -do - install_and_publish ${project} -done diff --git a/packages/lesspass-pure/vue.config.js b/packages/lesspass-pure/vue.config.js new file mode 100644 index 0000000..a3ed438 --- /dev/null +++ b/packages/lesspass-pure/vue.config.js @@ -0,0 +1,15 @@ +module.exports = { + css: { + extract: { + filename: "lesspass.min.css" + } + }, + configureWebpack: { + output: { + filename: "lesspass.min.js" + }, + optimization: { + splitChunks: false + } + } +}; diff --git a/packages/lesspass-web-extension/package.json b/packages/lesspass-web-extension/package.json index a496bb7..9be58d8 100644 --- a/packages/lesspass-web-extension/package.json +++ b/packages/lesspass-web-extension/package.json @@ -7,7 +7,6 @@ "scripts": { "start": "cd extension && web-ext run", "test": "echo 0", - "build": "cd ../.. && ./bin/build_web_extensions && cd packages/lesspass-web-extension", "release": "npm run release:cws && npm run release:amo", "release:amo": "cd extension && web-ext-submit", "release:cws": "cd extension && webstore upload --auto-publish"