Skip to content

Commit

Permalink
Update github_master.yml for pypi publish
Browse files Browse the repository at this point in the history
Signed-off-by: ramazanyetis <[email protected]>
  • Loading branch information
ramazanyetis authored Jul 26, 2023
1 parent 5a94eaf commit 48c903c
Showing 1 changed file with 63 additions and 36 deletions.
99 changes: 63 additions & 36 deletions .github/workflows/github_master.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,79 @@
name: Update Release Workflow
name: Update Release and Publish to PyPI Workflow

on:
push:
branches: [ "master" ]

jobs:
build:
build-n-publish:
name: Update Release and Publish iyzipay-python distributions to PyPI
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Update Release Number
run: |
set -e
# Retrieve the current release number
current_release=$(cat VERSION)
# If major version required uncomment below row
# current_release='<major_version_number>'
# - name: Update Release Number
# run: |
# set -e
#
# # Retrieve the current release number
# current_release=$(cat VERSION)
#
# # If major version required uncomment below row
# # current_release='<major_version_number>'
#
# # Increment the release number
# new_release=$(echo $current_release | awk -F. -v OFS=. '{$NF++;print}')
#
# # Set the new release number as an environment variable
# echo "NEW_RELEASE=${new_release}" >> $GITHUB_ENV
#
# # Change version number on files
# sed -i -e 's/'$current_release'/'$new_release'/g' setup.py iyzipay/iyzipay_resource.py VERSION

# Increment the release number
new_release=$(echo $current_release | awk -F. -v OFS=. '{$NF++;print}')
# Set the new release number as an environment variable
echo "NEW_RELEASE=${new_release}" >> $GITHUB_ENV
# - name: Github Tasks
# run: |
# set -e
# git config user.name "iyzico-ci"
# git config user.email [email protected]
# git add .
# git commit -m "Automatic commit by iyzico-ci v${{env.NEW_RELEASE}}"
# git push origin master
# git tag -a v${{env.NEW_RELEASE}} -m "Automatic tag by iyzico-ci v${{env.NEW_RELEASE}}"
# git push origin v${{env.NEW_RELEASE}}
#
# - name: Github Release
# run: |
# # Use the new release version in release creation step
# echo "Creating release ${{env.NEW_RELEASE}}..."
# result=$( curl -# -XPOST -H "Authorization: token ${{secrets.TOKEN_GITHUB}}" -H "Content-Type: application/json" -H "Accept:application/json" --data-binary '{"tag_name": "v${{env.NEW_RELEASE}}","target_commitish": "master","name": "iyzipay-python ${{env.NEW_RELEASE}}","body": "version ${{env.NEW_RELEASE}}","draft": false,"prerelease": false}' https://api.github.com/repos/iyzico/iyzipay-python/releases )
# echo $result
# echo "GitHub release ${{env.NEW_RELEASE}} created!"

# Change version number on files
sed -i -e 's/'$current_release'/'$new_release'/g' setup.py iyzipay/iyzipay_resource.py VERSION
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Github Tasks
run: |
set -e
git config user.name "iyzico-ci"
git config user.email [email protected]
git add .
git commit -m "Automatic commit by iyzico-ci v${{env.NEW_RELEASE}}"
git push origin master
git tag -a v${{env.NEW_RELEASE}} -m "Automatic tag by iyzico-ci v${{env.NEW_RELEASE}}"
git push origin v${{env.NEW_RELEASE}}
- name: Github Release
run: |
# Use the new release version in release creation step
echo "Creating release ${{env.NEW_RELEASE}}..."
result=$( curl -# -XPOST -H "Authorization: token ${{secrets.TOKEN_GITHUB}}" -H "Content-Type: application/json" -H "Accept:application/json" --data-binary '{"tag_name": "v${{env.NEW_RELEASE}}","target_commitish": "master","name": "iyzipay-python ${{env.NEW_RELEASE}}","body": "version ${{env.NEW_RELEASE}}","draft": false,"prerelease": false}' https://api.github.com/repos/iyzico/iyzipay-python/releases )
echo $result
echo "GitHub release ${{env.NEW_RELEASE}} created!"
- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TOKEN_PYPI }}
# repository-url: https://test.pypi.org/legacy/

0 comments on commit 48c903c

Please sign in to comment.