forked from sguermond/amazon-advertising-api-python
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66eeee7
commit 503240c
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | ||