This repository was archived by the owner on Jun 27, 2025. It is now read-only.
forked from sguermond/amazon-advertising-api-python
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython-bump2version-release.yaml
More file actions
91 lines (76 loc) · 3.33 KB
/
python-bump2version-release.yaml
File metadata and controls
91 lines (76 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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: Update develop version
id: dev_version
if: "${{ github.event_name == 'push' && github.event.repository.default_branch == github.ref_name }}"
run: |
bump2version patch --verbose --allow-dirty --no-commit
echo DEV_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: 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: Update remote
if: "${{ github.event_name == 'push' && github.event.repository.default_branch == github.ref_name }}"
run: |
git push origin ${{ github.ref_name }}
- 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/*