From 99b0bdbb6f3a2f8df270b1f193e16dbd03b9dea7 Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Tue, 15 Oct 2019 23:00:10 +0200 Subject: [PATCH] Add deploy actions --- .github/workflows/deploy.yml | 52 +++++++++++++++++++++++++++++ .github/workflows/main.yml | 57 -------------------------------- .github/workflows/test.yml | 66 +++++++++++++++++++++++++++++++++++++ README.md | 2 +- bin/tag | 2 +- containers/deploy | 24 +++++++------- containers/frontend | 1 + containers/test | 5 ++- netlify.toml | 4 --- packages/deploy | 15 +++++++++ packages/lesspass-site/package.json | 2 +- 11 files changed, 150 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/test.yml create mode 120000 containers/frontend delete mode 100644 netlify.toml create mode 100755 packages/deploy diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..184996b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: deploy + +on: + push: + branches: + - refs/tags/* + +jobs: + deploy-containers: + runs-on: ubuntu-latest + needs: test-containers + steps: + - uses: actions/checkout@v1 + - name: deploy containers + run: | + cd containers + ./deploy + env: + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + + deploy-packages: + runs-on: ubuntu-latest + needs: test-packages + steps: + - uses: actions/checkout@v1 + - name: deploy packages + run: | + cd packages + ./deploy + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + deploy-cli: + runs-on: ubuntu-latest + needs: test-cli + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: '3.x' + - name: deploy cli + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + cd cli + python -m pip install --upgrade pip + pip install setuptools wheel twine + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index b385a00..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: ci - -on: [push, pull_request] - -jobs: - test-javascript-packages: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: test javascript packages - run: | - yarn install - yarn test - - test-mobile-app: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: test mobile app - run: | - cd mobile - yarn install - yarn test - - test-python-cli: - runs-on: ubuntu-latest - strategy: - max-parallel: 3 - matrix: - python-version: [3.5, 3.6, 3.7] - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: test python cli - run: | - cd cli - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - python -m pip install -r test-requirements.txt - export PYTHONPATH='.' - python -m unittest discover - - test-python-backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: "3.6" - - name: test python backend - run: | - cd containers/backend - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - python manage.py test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ef1d934 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,66 @@ +name: test + +on: [push, pull_request] + +jobs: + test-packages: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: test packages + run: | + yarn install + yarn test + + test-mobile: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: test mobile + run: | + cd mobile + yarn install + yarn test + + test-cli: + runs-on: ubuntu-latest + strategy: + max-parallel: 3 + matrix: + python-version: [3.5, 3.6, 3.7] + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: test cli + run: | + cd cli + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python -m pip install -r test-requirements.txt + export PYTHONPATH='.' + python -m unittest discover + + test-backend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: "3.6" + - name: test backend + run: | + cd containers/backend + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python manage.py test + + test-containers: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: test containers + run: | + cd containers + ./test diff --git a/README.md b/README.md index a8938d0..c66076c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Actions Status](https://github.com/lesspass/lesspass/workflows/ci/badge.svg)](https://github.com/lesspass/lesspass/actions) [![Backers on Open Collective](https://opencollective.com/lesspass/backers/badge.svg)](CONTRIBUTING.md#backers) [![Sponsors on Open Collective](https://opencollective.com/lesspass/sponsors/badge.svg)](CONTRIBUTING.md#sponsors) +[![Actions Status](https://github.com/lesspass/lesspass/workflows/test/badge.svg)](https://github.com/lesspass/lesspass/actions) [![Backers on Open Collective](https://opencollective.com/lesspass/backers/badge.svg)](CONTRIBUTING.md#backers) [![Sponsors on Open Collective](https://opencollective.com/lesspass/sponsors/badge.svg)](CONTRIBUTING.md#sponsors) # LessPass diff --git a/bin/tag b/bin/tag index f61ff18..ea19426 100755 --- a/bin/tag +++ b/bin/tag @@ -56,10 +56,10 @@ function replace_versions_in_files { 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 - sed -i "s/\"version\": \"${1}\"/\"version\": \"${2}\"/g" containers/frontend/package.json sed -i "s/VERSION=\"${1}\"/VERSION=\"${2}\"/g" containers/deploy } diff --git a/containers/deploy b/containers/deploy index c77d812..d2d780e 100755 --- a/containers/deploy +++ b/containers/deploy @@ -1,16 +1,14 @@ #!/usr/bin/env bash set -e -VERSION="9.0.0" -podman login --username "${QUAI_USERNAME}" --password "${QUAI_PASSWORD}" quai.io -podman build --tag lesspass/webserver:${VERSION} --tag lesspass/webserver:latest ./webserver -podman build --tag lesspass/frontend:${VERSION} --tag lesspass/frontend:latest ./frontend -podman build --tag lesspass/backend:${VERSION} --tag lesspass/backend:latest ./backend -podman images -podman --version -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/webserver:${VERSION} docker://quai.io/lesspass/webserver -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/webserver:latest docker://quai.io/lesspass/webserver -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/frontend:${VERSION} docker://quai.io/lesspass/frontend -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/frontend:latest docker://quai.io/lesspass/frontend -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/backend:${VERSION} docker://quai.io/lesspass/backend -podman push --creds "${QUAI_USERNAME}:${QUAI_PASSWORD}" lesspass/backend:latest docker://quai.io/lesspass/backend \ No newline at end of file +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/containers/frontend b/containers/frontend new file mode 120000 index 0000000..f83e202 --- /dev/null +++ b/containers/frontend @@ -0,0 +1 @@ +../packages/lesspass-site/ \ No newline at end of file diff --git a/containers/test b/containers/test index 6757893..7f6fbf4 100755 --- a/containers/test +++ b/containers/test @@ -1,11 +1,10 @@ #!/usr/bin/env bash set -e -# containers export COMPOSE_PROJECT_NAME=lesspass docker-compose build docker-compose down -v docker-compose up -d -docker exec -it lesspass_backend_1 sh -c 'python wait_db.py' -docker exec -it lesspass_backend_1 sh -c 'python manage.py test' +docker exec lesspass_backend_1 sh -c 'python wait_db.py' +docker exec lesspass_backend_1 sh -c 'python manage.py test' docker-compose down -v diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index 20c56eb..0000000 --- a/netlify.toml +++ /dev/null @@ -1,4 +0,0 @@ -[build] - base = "packages/lesspass-site/" - publish = "packages/lesspass-site/build/" - command = "yarn build" \ No newline at end of file diff --git a/packages/deploy b/packages/deploy new file mode 100755 index 0000000..256b632 --- /dev/null +++ b/packages/deploy @@ -0,0 +1,15 @@ +#!/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-site/package.json b/packages/lesspass-site/package.json index a061c83..21a91c9 100644 --- a/packages/lesspass-site/package.json +++ b/packages/lesspass-site/package.json @@ -1,5 +1,5 @@ { - "name": "lesspass-web-site", + "name": "lesspass-site", "version": "9.0.0", "description": "LessPass web site", "license": "GPL-3.0",