From 9cb150a9d4703266f9e53144b731d8c6c29443f2 Mon Sep 17 00:00:00 2001 From: Zhongnan Su Date: Wed, 6 May 2020 16:22:58 -0700 Subject: [PATCH] Added github action workflow for CI/CD (#31) --- .github/workflows/release-workflow.yml | 53 +++++++++++++++++++ .github/workflows/test-and-build-workflow.yml | 44 +++++++++++++++ odfesql_cli/__init__.py | 2 +- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-workflow.yml create mode 100644 .github/workflows/test-and-build-workflow.yml diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml new file mode 100644 index 0000000..024e293 --- /dev/null +++ b/.github/workflows/release-workflow.yml @@ -0,0 +1,53 @@ +name: Release SQL CLI Artifacts +# This workflows is triggered on creating tags to master or an opendistro release branch +on: + push: + # TODO: use tags in next release + branches: + - 'opendistro-*' + +jobs: + build: + + runs-on: [ubuntu-16.04] + strategy: + matrix: + python-version: [3.8] + + steps: + - name: Checkout SQL CLI + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + # publish to S3 and PyPI + - name: Build and Publish + run: | + python setup.py sdist bdist_wheel + artifact=`ls ./dist/*.tar.gz` + wheel_artifact= `ls ./dist/*.whl` + + aws s3 cp $artifact s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/elasticsearch-clients/opendistro-sql-cli/ + aws s3 cp $wheel_artifact s3://artifacts.opendistroforelasticsearch.amazon.com/downloads/elasticsearch-clients/opendistro-sql-cli/ + + # aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/downloads/*" + + # TODO: Publish to PyPI + # env: + # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + # run: twine upload dist/* \ No newline at end of file diff --git a/.github/workflows/test-and-build-workflow.yml b/.github/workflows/test-and-build-workflow.yml new file mode 100644 index 0000000..16fe378 --- /dev/null +++ b/.github/workflows/test-and-build-workflow.yml @@ -0,0 +1,44 @@ +name: Test and Build + +on: [pull_request, push] + +jobs: + build: + + runs-on: [ubuntu-16.04] + strategy: + matrix: + python-version: [3.8] + + steps: + - name: Checkout SQL CLI + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + pip install setuptools wheel + + # TODO: this test will pass, because we haven't spin up an ES instance + - name: Run Tox Testing + run: tox + + - name: Build Artifact + run: python setup.py sdist bdist_wheel + + - name: Create Artifact Path + run: | + mkdir -p opendistro-sql-cli-builds + cp -r ./dist/*.tar.gz ./dist/*.whl opendistro-sql-cli-builds/ + + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: opendistro-sql-cli + path: opendistro-sql-cli-builds \ No newline at end of file diff --git a/odfesql_cli/__init__.py b/odfesql_cli/__init__.py index 77afd36..c73b430 100644 --- a/odfesql_cli/__init__.py +++ b/odfesql_cli/__init__.py @@ -12,4 +12,4 @@ See the License for the specific language governing permissions and limitations under the License. """ -__version__ = "1.0" +__version__ = "1.7.0.0"