Skip to content

Commit

Permalink
[DEV-3804] Use local workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
RustamGimadiev committed Aug 11, 2023
1 parent 66eeee7 commit 503240c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/python-bump2version-release.yaml
Original file line number Diff line number Diff line change
@@ -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 '[email protected]'
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 }}

0 comments on commit 503240c

Please sign in to comment.