From 66eeee786048f936e578356c9ee67c10558bb6cc Mon Sep 17 00:00:00 2001 From: RustamGimadiev Date: Fri, 11 Aug 2023 15:53:49 +0300 Subject: [PATCH 1/6] [DEV-3804] Add GA workflows --- .argo-ci/master.yaml | 255 ----------------------------- .argo-ci/pr.yaml | 254 ---------------------------- .argo-ci/release.yaml | 154 ----------------- .bumpversion.cfg | 2 +- .github/workflows/build.yaml | 62 +++++++ amazon_advertising_api/versions.py | 2 +- 6 files changed, 64 insertions(+), 665 deletions(-) delete mode 100644 .argo-ci/master.yaml delete mode 100644 .argo-ci/pr.yaml delete mode 100644 .argo-ci/release.yaml create mode 100644 .github/workflows/build.yaml 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..0713646 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,62 @@ +name: PR build and publish + +on: + pull_request: + branches: + - master + push: + branches: + - master + +defaults: + run: + shell: bash + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Setup Python version + uses: actions/setup-python@v4 + with: + python-version: "3.7" + + - name: Run tests + run: | + python -m pip install --upgrade pip setuptools wheel + pip install pipenv + pipenv install --dev + pipenv run pytest --disable-pytest-warnings + + call-workflow-versioning: + needs: [test] + uses: pepsico-ecommerce/ops-gh-workflows/.github/workflows/python-bump2version-release.yaml@DEV-3809 + 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/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', From 503240c771b3959603f4e9ba732180e94adddf48 Mon Sep 17 00:00:00 2001 From: RustamGimadiev Date: Fri, 11 Aug 2023 15:57:53 +0300 Subject: [PATCH 2/6] [DEV-3804] Use local workflow --- .github/workflows/build.yaml | 2 +- .../python-bump2version-release.yaml | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/python-bump2version-release.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0713646..23c29d7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -35,7 +35,7 @@ jobs: call-workflow-versioning: needs: [test] - uses: pepsico-ecommerce/ops-gh-workflows/.github/workflows/python-bump2version-release.yaml@DEV-3809 + uses: ./.github/workflows/python-bump2version-release.yaml secrets: TWINE_USERNAME: ${{ secrets.NEXUS_PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.NEXUS_PYPI_PASSWORD }} diff --git a/.github/workflows/python-bump2version-release.yaml b/.github/workflows/python-bump2version-release.yaml new file mode 100644 index 0000000..385ad88 --- /dev/null +++ b/.github/workflows/python-bump2version-release.yaml @@ -0,0 +1,78 @@ +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 + env: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + run: | + python -m build + twine upload --repository-url https://nexus.pepstaging.com/repository/pypi-dev/ 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 From 422b9e9b35a6631be0c162dd41eadc76bcc1a0e6 Mon Sep 17 00:00:00 2001 From: RustamGimadiev Date: Fri, 11 Aug 2023 16:06:40 +0300 Subject: [PATCH 3/6] [DEV-3804] Disable tests --- .github/workflows/build.yaml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 23c29d7..938b312 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,21 +20,8 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 - - - name: Setup Python version - uses: actions/setup-python@v4 - with: - python-version: "3.7" - - - name: Run tests - run: | - python -m pip install --upgrade pip setuptools wheel - pip install pipenv - pipenv install --dev - pipenv run pytest --disable-pytest-warnings call-workflow-versioning: - needs: [test] uses: ./.github/workflows/python-bump2version-release.yaml secrets: TWINE_USERNAME: ${{ secrets.NEXUS_PYPI_USERNAME }} From 263f2525684d91d968a2cb795976c9653cca09a6 Mon Sep 17 00:00:00 2001 From: garegincontractor <“Garegin.Tamrazyan.Contractor@pepsico.com”> Date: Fri, 22 Sep 2023 12:38:00 +0400 Subject: [PATCH 4/6] add Build and publish to release step --- .github/workflows/python-bump2version-release.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-bump2version-release.yaml b/.github/workflows/python-bump2version-release.yaml index 385ad88..d199431 100644 --- a/.github/workflows/python-bump2version-release.yaml +++ b/.github/workflows/python-bump2version-release.yaml @@ -56,14 +56,24 @@ jobs: bump2version release --serialize {major}.{minor}.{patch} --verbose --allow-dirty echo RELEASE_VERSION=$(python setup.py --version) >> $GITHUB_OUTPUT - - name: Build and publish + - 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: "${{ startsWith(github.ref, 'refs/tags/') }}" + 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 }}" From 20d056c225e1c51cc40440f9f8844e9a29f6e8f7 Mon Sep 17 00:00:00 2001 From: garegincontractor <“Garegin.Tamrazyan.Contractor@pepsico.com”> Date: Fri, 22 Sep 2023 13:07:08 +0400 Subject: [PATCH 5/6] let the workflow to be triggered on new tag --- .github/workflows/build.yaml | 2 ++ .github/workflows/python-bump2version-release.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 938b312..1512715 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,6 +7,8 @@ on: push: branches: - master + tags: + - '*' defaults: run: diff --git a/.github/workflows/python-bump2version-release.yaml b/.github/workflows/python-bump2version-release.yaml index d199431..de53a0f 100644 --- a/.github/workflows/python-bump2version-release.yaml +++ b/.github/workflows/python-bump2version-release.yaml @@ -69,7 +69,7 @@ jobs: env: TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - if: "${{ startsWith(github.ref, 'refs/tags/') }}" + if: "${{ github.ref_type == 'tag' }}" run: | python -m build twine upload --repository-url https://nexus.pepstaging.com/repository/pypi-release/ dist/* From a263f8cc3436818993e5526bb5a8f81b6d3a13cb Mon Sep 17 00:00:00 2001 From: garegincontractor <“Garegin.Tamrazyan.Contractor@pepsico.com”> Date: Fri, 22 Sep 2023 15:17:19 +0400 Subject: [PATCH 6/6] minor correction --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1512715..b608fec 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,7 +8,7 @@ on: branches: - master tags: - - '*' + - '*' defaults: run: