diff --git a/.argo-ci/master.yaml b/.argo-ci/master.yaml
deleted file mode 100644
index 4d36d7a..0000000
--- a/.argo-ci/master.yaml
+++ /dev/null
@@ -1,255 +0,0 @@
-apiVersion: argoproj.io/v1alpha1
-kind: Workflow
-metadata:
- generateName: amazon-advertising-api-python-master-
-spec:
- # entrypoint is the name of the template used as the starting point of the workflow
- entrypoint: run-check
- onExit: exit-handler
- arguments:
- parameters:
- - name: git_url
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: repo_name
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: commit_message
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: sha
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- # a temporary volume, named workdir, will be used as a working directory
- # for this workflow. This volume is passed around from step to step.
- volumeClaimTemplates:
- - metadata:
- name: workdir
- spec:
- accessModes: [ "ReadWriteOnce" ]
- resources:
- requests:
- storage: 1Gi
- volumes:
- - name: sshkey
- secret:
- secretName: argo-ci-git-ssh-key
- items:
- - key: id_rsa
- mode: 0400
- path: id_rsa
- - name: known-hosts
- secret:
- secretName: known-github
- - name: pypirc
- secret:
- secretName: nexus-pypi
- items:
- - key: .pypirc
- path: .pypirc
-
-
-
- templates:
- - name: run-check
- steps:
- - - name: check-commit-messsage
- template: check-message-script
-
- - - name: run-build
- template: run-build
- when: "{{steps.check-commit-messsage.outputs.result}} != skip"
-
-
- - name: run-build
- steps:
- - - name: set-pending
- template: status-update
- arguments:
- parameters:
- - name: status
- value: pending
- - name: message
- value: Argo CI tests has been started
-
- - - name: get-package-name
- template: generate-name
-
- - - name: checkout
- template: git
- arguments:
- parameters:
- - name: cmd
- value: >
- cd /workdir &&
- git clone {{workflow.parameters.git_url}} &&
- cd /workdir/{{workflow.parameters.repo_name}} &&
- git checkout master
-
- - - name: alpha-version-bump
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install bump2version &&
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- bump2version patch
- --verbose
- --allow-dirty
- --no-commit
-
- - - name: pack-and-push
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install twine &&
- python3 setup.py sdist bdist_wheel &&
- twine upload --config-file /etc/pypirc/.pypirc -r pepsico-ecommerce-dev dist/*
-
- - - name: version-bump
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install bump2version &&
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- bump2version release
- --serialize {major}.{minor}.{patch}
- --verbose
- --allow-dirty
-
- - - name: git-push
- template: git
- arguments:
- parameters:
- - name: cmd
- value: >
- cd /workdir/{{workflow.parameters.repo_name}} &&
- git push origin master
-
-
-
- - name: exit-handler
- steps:
- - - name: success
- template: status-update
- arguments:
- parameters:
- - name: status
- value: success
- - name: message
- value: Version bumped and package deployed.
- when: "{{workflow.status}} == Succeeded"
- - name: failure
- template: status-update
- arguments:
- parameters:
- - name: status
- value: failure
- - name: message
- value: Something went wrong, check logs in details.
- when: "{{workflow.status}} != Succeeded"
-
- - name: git
- inputs:
- parameters:
- - name: cmd
- container:
- image: "alpine/git"
- command: ["sh", "-c"]
- args:
- - >
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: sshkey
- mountPath: /root/.ssh
- - mountPath: /etc/ssh
- name: known-hosts
-
- - name: python
- inputs:
- parameters:
- - name: cmd
- container:
- image: "python:3.7-buster"
- command: ["sh", "-c"]
- args:
- - >
- cd /workdir/{{workflow.parameters.repo_name}} &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: pypirc
- mountPath: /etc/pypirc/
- env:
- - name: NEXUS_PYPI_PASSWORD
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: password
- - name: NEXUS_PYPI_USERNAME
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: username
-
- - name: status-update
- inputs:
- parameters:
- - name: status
- - name: message
- container:
- image: cloudposse/github-status-updater
- env:
- - name: GITHUB_ACTION
- value: update_state
- - name: GITHUB_TOKEN
- valueFrom:
- secretKeyRef:
- name: github-access-token
- key: token
- - name: GITHUB_OWNER
- value: pepsico-ecommerce
- - name: GITHUB_REPO
- value: "{{workflow.parameters.repo_name}}"
- - name: GITHUB_REF
- value: "{{workflow.parameters.sha}}"
- - name: GITHUB_CONTEXT
- value: Dev package published
- - name: GITHUB_STATE
- value: "{{inputs.parameters.status}}"
- - name: GITHUB_DESCRIPTION
- value: "{{inputs.parameters.message}}"
- - name: GITHUB_TARGET_URL
- value: "https://argo-wf.pepstaging.com/workflows/argo-events/{{workflow.name}}"
-
- - name: check-message-script
- script:
- image: python:alpine3.7
- command: [python]
- source: |
- message = """
- {{workflow.parameters.commit_message}}
- """
- if "Bump version:" in message:
- print("skip")
- else:
- print("Building")
-
- - name: generate-name
- script:
- image: python:alpine3.7
- command: [python]
- source: |
- repo_name = """
- {{workflow.parameters.repo_name}}
- """
- package_name = repo_name.strip().replace('"', '').replace("'", "").replace('-', '_')
- print(package_name)
diff --git a/.argo-ci/pr.yaml b/.argo-ci/pr.yaml
deleted file mode 100644
index 60a510f..0000000
--- a/.argo-ci/pr.yaml
+++ /dev/null
@@ -1,254 +0,0 @@
-apiVersion: argoproj.io/v1alpha1
-kind: Workflow
-metadata:
- generateName: amazon-advertising-api-python-pr-
-spec:
- # entrypoint is the name of the template used as the starting point of the workflow
- entrypoint: run-tests
- onExit: exit-handler
- arguments:
- parameters:
- - name: git_url
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: source_branch
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: target_branch
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: repo_name
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: source_sha
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: pr_number
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- # a temporary volume, named workdir, will be used as a working directory
- # for this workflow. This volume is passed around from step to step.
- volumeClaimTemplates:
- - metadata:
- name: workdir
- spec:
- accessModes: [ "ReadWriteOnce" ]
- resources:
- requests:
- storage: 1Gi
- volumes:
- - name: sshkey
- secret:
- secretName: argo-ci-git-ssh-key
- items:
- - key: id_rsa
- mode: 0400
- path: id_rsa
- - name: known-hosts
- secret:
- secretName: known-github
- - name: pypirc
- secret:
- secretName: nexus-pypi
- items:
- - key: .pypirc
- path: .pypirc
-
-
-
- templates:
- - name: run-tests
- steps:
- - - name: set-pending
- template: status-update
- arguments:
- parameters:
- - name: status
- value: pending
- - name: message
- value: Argo CI tests has been started
-
- - - name: checkout
- template: git
- arguments:
- parameters:
- - name: cmd
- value: >
- cd /workdir &&
- git clone {{workflow.parameters.git_url}} &&
- cd {{workflow.parameters.repo_name}} &&
- git fetch &&
- git merge origin/{{workflow.parameters.source_branch}}
-
- - - name: get-package-name
- template: generate-name
-
- - - name: version-bump
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install bump2version &&
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- bump2version release --allow-dirty --verbose
- --serialize 0.0.0-dev{{workflow.parameters.source_sha}} &&
- python setup.py -V > /version
-
- - - name: pack-and-push
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install twine &&
- python3 setup.py sdist bdist_wheel &&
- twine upload --verbose --config-file /etc/pypirc/.pypirc -r pepsico-ecommerce-dev dist/*
-
- - - name: comment-pr
- template: PR-comment
- arguments:
- parameters:
- - name: message
- value: "Looks good to me! and your package is here \
- {{steps.version-bump.outputs.parameters.version}}"
-
-
-
- - name: exit-handler
- steps:
- - - name: success
- template: status-update
- arguments:
- parameters:
- - name: status
- value: success
- - name: message
- value: All tests has passed in argo ci
- when: "{{workflow.status}} == Succeeded"
- - name: failure
- template: status-update
- arguments:
- parameters:
- - name: status
- value: failure
- - name: message
- value: Some tests has failed, check details for logs
- when: "{{workflow.status}} != Succeeded"
-
- - name: git
- inputs:
- parameters:
- - name: cmd
- container:
- image: "alpine/git"
- command: ["sh", "-c"]
- args:
- - >
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: sshkey
- mountPath: /root/.ssh
- - mountPath: /etc/ssh
- name: known-hosts
-
- - name: python
- inputs:
- parameters:
- - name: cmd
- outputs:
- parameters:
- - name: version # name of output parameter
- valueFrom:
- path: /version
- container:
- image: "python:3.7-buster"
- command: ["sh", "-c"]
- args:
- - >
- touch /version &&
- cd /workdir/{{workflow.parameters.repo_name}} &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: pypirc
- mountPath: /etc/pypirc/
- env:
- - name: NEXUS_PYPI_PASSWORD
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: password
- - name: NEXUS_PYPI_USERNAME
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: username
-
- - name: status-update
- inputs:
- parameters:
- - name: status
- - name: message
- container:
- image: cloudposse/github-status-updater
- env:
- - name: GITHUB_ACTION
- value: update_state
- - name: GITHUB_TOKEN
- valueFrom:
- secretKeyRef:
- name: github-access-token
- key: token
- - name: GITHUB_OWNER
- value: pepsico-ecommerce
- - name: GITHUB_REPO
- value: "{{workflow.parameters.repo_name}}"
- - name: GITHUB_REF
- value: "{{workflow.parameters.source_sha}}"
- - name: GITHUB_CONTEXT
- value: Argo CI Workflow
- - name: GITHUB_STATE
- value: "{{inputs.parameters.status}}"
- - name: GITHUB_DESCRIPTION
- value: "{{inputs.parameters.message}}"
- - name: GITHUB_TARGET_URL
- value: "https://argo-wf.pepstaging.com/workflows/argo-events/{{workflow.name}}"
-
- - name: PR-comment
- inputs:
- parameters:
- - name: message
- container:
- image: cloudposse/github-commenter
- env:
- - name: GITHUB_TOKEN
- valueFrom:
- secretKeyRef:
- name: github-access-token
- key: token
- - name: GITHUB_OWNER
- value: pepsico-ecommerce
- - name: GITHUB_REPO
- value: "{{workflow.parameters.repo_name}}"
- - name: GITHUB_COMMENT_TYPE
- value: pr
- - name: GITHUB_PR_ISSUE_NUMBER
- value: "{{workflow.parameters.pr_number}}"
- - name: GITHUB_COMMENT_FORMAT
- value: "Argo CI comment: {{.}}"
- - name: GITHUB_COMMENT
- value: "{{inputs.parameters.message}}"
- - name: GITHUB_DELETE_COMMENT_REGEX
- value: "^Argo CI comment"
-
- - name: generate-name
- script:
- image: python:alpine3.7
- command: [python]
- source: |
- repo_name = """
- {{workflow.parameters.repo_name}}
- """
- package_name = repo_name.strip().replace('"', '').replace("'", "").replace('-', '_')
- print(package_name)
diff --git a/.argo-ci/release.yaml b/.argo-ci/release.yaml
deleted file mode 100644
index 76a660b..0000000
--- a/.argo-ci/release.yaml
+++ /dev/null
@@ -1,154 +0,0 @@
-apiVersion: argoproj.io/v1alpha1
-kind: Workflow
-metadata:
- generateName: amazon-advertising-api-python-release-
-spec:
- # entrypoint is the name of the template used as the starting point of the workflow
- entrypoint: run-build
- # onExit: exit-handler
- arguments:
- parameters:
- - name: git_url
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: tag_name
- value: HAS_TO_BE_PASSED_FROM_SENSOR
- - name: repo_name
- value: HAS_TO_BE_PASSED_FROM_SENSOR
-
- # a temporary volume, named workdir, will be used as a working directory
- # for this workflow. This volume is passed around from step to step.
- volumeClaimTemplates:
- - metadata:
- name: workdir
- spec:
- accessModes: [ "ReadWriteOnce" ]
- resources:
- requests:
- storage: 1Gi
- volumes:
- - name: sshkey
- secret:
- secretName: argo-ci-git-ssh-key
- items:
- - key: id_rsa
- mode: 0400
- path: id_rsa
- - name: known-hosts
- secret:
- secretName: known-github
- - name: pypirc
- secret:
- secretName: nexus-pypi
- items:
- - key: .pypirc
- path: .pypirc
-
-
-
- templates:
- - name: run-build
- steps:
- - - name: checkout
- template: git
- arguments:
- parameters:
- - name: cmd
- value: >
- cd /workdir &&
- git clone {{workflow.parameters.git_url}} &&
- cd /workdir/{{workflow.parameters.repo_name}} &&
- git checkout tags/{{workflow.parameters.tag_name}}
-
- - - name: compare-version
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- if [ $(python setup.py --version) = {{workflow.parameters.tag_name}} ];
- then
- echo OK;
- else
- exit 1;
- fi
-### add notification to slack if fail
-
- - - name: get-package-name
- template: generate-name
-
- - - name: pack-and-push
- template: python
- arguments:
- parameters:
- - name: cmd
- value: >
- pip install twine &&
- python3 setup.py sdist bdist_wheel &&
- twine upload --config-file /etc/pypirc/.pypirc -r pepsico-ecommerce-release dist/*
-
-### slack notification about new version
-
-
-
- - name: git
- retryStrategy:
- limit: 3
- inputs:
- parameters:
- - name: cmd
- container:
- image: "alpine/git"
- command: ["sh", "-c"]
- args:
- - >
- git config --global user.email 'argo-ci@pepsi.co' &&
- git config --global user.name 'Argo CI' &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: sshkey
- mountPath: /root/.ssh
- - mountPath: /etc/ssh
- name: known-hosts
-
- - name: python
- retryStrategy:
- limit: 3
- inputs:
- parameters:
- - name: cmd
- container:
- image: "python:3.7-buster"
- command: ["sh", "-c"]
- args:
- - >
- cd /workdir/{{workflow.parameters.repo_name}} &&
- {{inputs.parameters.cmd}}
- volumeMounts:
- - name: workdir
- mountPath: /workdir
- - name: pypirc
- mountPath: /etc/pypirc/
- env:
- - name: NEXUS_PYPI_PASSWORD
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: password
- - name: NEXUS_PYPI_USERNAME
- valueFrom:
- secretKeyRef:
- name: nexus-pypi-ro-creds
- key: username
-
- - name: generate-name
- script:
- image: python:alpine3.7
- command: [python]
- source: |
- repo_name = """
- {{workflow.parameters.repo_name}}
- """
- package_name = repo_name.strip().replace('"', '').replace("'", "").replace('-', '_')
- print(package_name)
diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index 9033ac9..18c4ae3 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.0.12
+current_version = 0.0.12-alpha
commit = True
tag = False
message = "Bump version: {current_version} → {new_version}"
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..b608fec
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,51 @@
+name: PR build and publish
+
+on:
+ pull_request:
+ branches:
+ - master
+ push:
+ branches:
+ - master
+ tags:
+ - '*'
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ test:
+ name: Run tests
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ call-workflow-versioning:
+ uses: ./.github/workflows/python-bump2version-release.yaml
+ secrets:
+ TWINE_USERNAME: ${{ secrets.NEXUS_PYPI_USERNAME }}
+ TWINE_PASSWORD: ${{ secrets.NEXUS_PYPI_PASSWORD }}
+
+ pr-update:
+ name: Pull request comment
+ needs: [call-workflow-versioning]
+ if: github.event_name == 'pull_request'
+ runs-on: ubuntu-latest
+ steps:
+
+ - uses: technote-space/workflow-conclusion-action@v3
+
+ - name: Post Github comment
+ if: env.WORKFLOW_CONCLUSION == 'success'
+ uses: docker://cloudposse/github-commenter:0.19.0
+ env:
+ GITHUB_OWNER: ${{github.repository_owner}}
+ GITHUB_REPO: ${{github.event.repository.name}}
+ GITHUB_COMMENT_TYPE: pr
+ GITHUB_PR_ISSUE_NUMBER: ${{github.event.number}}
+ GITHUB_TOKEN: ${{github.token}}
+ GITHUB_COMMENT: |
+ Looks good to me! and your package is here ${{ needs.call-workflow-versioning.outputs.pr_version }}
diff --git a/.github/workflows/python-bump2version-release.yaml b/.github/workflows/python-bump2version-release.yaml
new file mode 100644
index 0000000..de53a0f
--- /dev/null
+++ b/.github/workflows/python-bump2version-release.yaml
@@ -0,0 +1,88 @@
+name: Manage version of Python package
+
+on:
+ workflow_call:
+ outputs:
+ development_version:
+ value: ${{ jobs.increase-version.outputs.development_version }}
+ release_version:
+ value: ${{ jobs.increase-version.outputs.release_version }}
+ pr_version:
+ value: ${{ jobs.increase-version.outputs.pr_version }}
+ secrets:
+ TWINE_USERNAME:
+ required: true
+ TWINE_PASSWORD:
+ required: true
+
+jobs:
+ increase-version:
+ name: Increase version
+ outputs:
+ development_version: ${{ steps.dev_version.outputs.DEV_VERSION }}
+ release_version: ${{ steps.release_version.outputs.RELEASE_VERSION }}
+ pr_version: ${{ steps.pr_version.outputs.PR_VERSION }}
+ runs-on: ubuntu-latest
+ steps:
+
+ - name: Checkout code
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 1
+
+ - name: Setup Python version
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.7"
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip build wheel twine
+ pip install bump2version
+ git config --global user.email 'pepecomminfra@pepsico.com'
+ git config --global user.name 'Github Actions'
+
+ - name: Increase version for PR
+ id: pr_version
+ if: "${{ github.event_name == 'pull_request' && github.event.repository.default_branch == github.event.pull_request.base.ref }}"
+ run: |
+ bump2version release --allow-dirty --verbose --serialize {major}.{minor}.{patch}-dev${{ github.event.number }}${{github.run_number}}
+ echo PR_VERSION=$(python setup.py --version) >> $GITHUB_OUTPUT
+
+ - name: Release version
+ id: release_version
+ if: "${{ github.event_name == 'push' && github.event.repository.default_branch == github.ref_name }}"
+ run: |
+ bump2version release --serialize {major}.{minor}.{patch} --verbose --allow-dirty
+ echo RELEASE_VERSION=$(python setup.py --version) >> $GITHUB_OUTPUT
+
+ - name: Build and publish to dev
+ env:
+ TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
+ TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
+ if: "${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.event.repository.default_branch == github.ref_name) }}"
+ run: |
+ python -m build
+ twine upload --repository-url https://nexus.pepstaging.com/repository/pypi-dev/ dist/*
+
+ - name: Build and publish to release
+ env:
+ TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
+ TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
+ if: "${{ github.ref_type == 'tag' }}"
+ run: |
+ python -m build
+ twine upload --repository-url https://nexus.pepstaging.com/repository/pypi-release/ dist/*
+
+ - name: Update develop version
+ id: dev_version
+ if: "${{ github.event_name == 'push' && github.event.repository.default_branch == github.ref_name }}"
+ run: |
+ bump2version patch --serialize {major}.{minor}.{patch}-{release} --verbose --allow-dirty
+ echo DEV_VERSION=$(python setup.py --version) >> $GITHUB_OUTPUT
+
+ - name: Update remote
+ if: "${{ github.event_name == 'push' && github.event.repository.default_branch == github.ref_name }}"
+ run: |
+ git push origin ${{ github.ref_name }}
+
\ No newline at end of file
diff --git a/amazon_advertising_api/versions.py b/amazon_advertising_api/versions.py
index 03fe368..f2ef88b 100644
--- a/amazon_advertising_api/versions.py
+++ b/amazon_advertising_api/versions.py
@@ -1,4 +1,4 @@
-__version__ = "0.0.12"
+__version__ = "0.0.12-alpha"
versions = {
'api_version': 'v2',