Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
uses: actions/checkout@v3

- name: Download shell script for checking input parameters
run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/build_git-tag_or_create_github-release.sh --output ./scripts/ci/build_git-tag_or_create_github-release.sh
run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/build_git-tag_or_create_github-release.sh --output ./scripts/ci/build_git-tag_or_create_github-release.sh

# This flow for the project type is Python project
- name: Build git tag and create GitHub release for Python project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Combine all testing coverage data files with test type and runtime OS, and convert to XML format file finally
run: |
curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/combine_coverage_reports.sh --output ./scripts/ci/combine_coverage_reports.sh
curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/combine_coverage_reports.sh --output ./scripts/ci/combine_coverage_reports.sh
bash ./scripts/ci/combine_coverage_reports.sh ${{ inputs.test_type }}

- name: Upload testing coverage report (.coverage)
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/push_pkg_to_pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#########################################################################################################################
#
# Workflow Description:
# Push the Python package to PyPI. (Official release the Python package)
#
# Workflow input parameters:
# * General arguments:
# * release-type: The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'.
# It won't push the package to PyPI if it's 'Pre-Release'.
# * push-to-PyPI: Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'.
#
# * Secret arguments:
# * PyPI_user: The username of PyPI.
# * PyPI_token: The password token of PyPI.
#
# Workflow running output:
# No and do nothing.
#
#########################################################################################################################

name: Push the Python package to PyPI

on:
workflow_call:
inputs:
release-type:
description: "The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. It won't
push the package to PyPI if it's 'Pre-Release'."
type: string
required: true
push-to-PyPI:
description: "Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'."
type: string
required: false
default: 'test'

secrets:
PyPI_user:
description: "The username of PyPI."
required: true
PyPI_token:
description: "The password token of PyPI."
required: true


jobs:
push_to_PyPI:
if: ${{ inputs.release-type == 'Official-Release' }}
runs-on: ubuntu-latest
steps:
- name: Download shell script for checking input parameters
run: |
curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check_getting_output.sh --output ./scripts/ci/check_getting_output.sh
bash ./scripts/ci/check_getting_output.sh

- name: Setup Python 3.10 in Ubuntu OS
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install -U pip
pip3 install -U setuptools
pip3 install wheel
pip3 install twine

- name: Compile and package the code as Python package formatter
run: python3 setup.py sdist bdist_wheel

- name: Push Python package to test PyPI
if: ${{ inputs.push-to-PyPI == 'test' }}
run: python3 -m twine upload --repository testpypi ./dist/*
env:
TWINE_USERNAME: ${{ secrets.PyPI_user }}
TWINE_PASSWORD: ${{ secrets.PyPI_token }}

- name: Push Python package to official PyPI
if: ${{ inputs.push-to-PyPI == 'official' }}
run: python3 -m twine upload ./dist/*
env:
TWINE_USERNAME: ${{ secrets.PyPI_user }}
TWINE_PASSWORD: ${{ secrets.PyPI_token }}
52 changes: 10 additions & 42 deletions .github/workflows/test_python_project_ci_one-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,47 +113,15 @@ jobs:
debug_mode: true


fake_build_pkg_and_push_to_pypi:
# name: Check about it could work finely by installing the Python package with setup.py file
push_python_pkg_to_pypi:
# name: Upload the Python package files which has been compiled to PyPi
if: github.event_name == 'push' && github.ref_name == 'release'
needs: build_git-tag_and_create_github-release
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
RELEASE_TYPE: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check it whether get the output of previous one job which has version info or not
run: bash scripts/ci/check_getting_output.sh
# run: |
# release_version=$(echo $RELEASE_TYPE)
# if [ "$release_version" != "" ]; then
# echo "📬🎉🍻 It gets data which is release version info!"
# exit 0
# else
# echo "📭🙈 It doesn't get any data which is release version info."
# exit 1
# fi

- name: For testing about getting the software version info
run: |
echo "Release version: $RELEASE_TYPE"


# compile_and_build_python_pkg:
## name: Compile the Python source code and build it as Python package files
# if: github.event_name == 'push' && github.ref_name == 'master'
# needs: pre-building_check
# uses: ./.github/workflows/build_package.yaml


# push_python_pkg_to_pypi:
## name: Upload the Python package files which has been compiled to PyPi
# if: github.event_name == 'push' && github.ref_name == 'master'
# needs: compile_and_build_python_pkg
# uses: ./.github/workflows/push_pkg_to_pypi.yaml
# secrets:
# pypi_user: ${{ secrets.PYPI_USERNAME }}
# pypi_token: ${{ secrets.PYPI_PASSWORD }}
uses: ./.github/workflows/push_pkg_to_pypi.yaml
with:
release-type: ${{ needs.build_git-tag_and_create_github-release.outputs.python_release_version }}
push-to-PyPI: test
secrets:
pypi_user: ${{ secrets.PYPI_USERNAME }}
pypi_token: ${{ secrets.PYPI_PASSWORD }}

2 changes: 1 addition & 1 deletion .github/workflows/upload_test_cov_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
uses: actions/checkout@v3

- name: Download shell script for checking input parameters
run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Workflow-Template-Python/develop/scripts/ci/check-input-params.sh --output ./scripts/ci/check-input-params.sh
run: curl https://raw.githubusercontent.com/Chisanan232/GitHub-Action_Reusable_Workflows-Python/develop/scripts/ci/check-input-params.sh --output ./scripts/ci/check-input-params.sh

- name: Check the workflow input parameter
run: |
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The usage of each workflow template.
* [_upload_test_cov_report.yaml_](#upload_test_cov_reportyaml)
* [_pre-building_test.yaml_](#pre-building_testyaml)
* [_build_git-tag_and_create_github-release.yaml_](#build_git-tag_and_create_github-releaseyaml)
* [_push_pkg_to_pypi.yaml_](#push_pkg_to_pypiyaml)

<hr>

Expand Down Expand Up @@ -341,3 +342,44 @@ The badge it generates:

[![Release](https://img.shields.io/github/release/Chisanan232/GitHub-Action-Template-Python.svg?label=Release&logo=github)](https://github.com/Chisanan232/GitHub-Action-Template-Python/releases)

<hr>

### _push_pkg_to_pypi.yaml_

* Description: Compile source code and push the Python package to PyPI. (Official release the Python package)
* Options:

It has 2 different types option could use:

_General option_:

| option name | data type | optional or required | function content |
|--------------|-----------|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| release-type | string | Required | The type of release processing. It has 2 type options: 'Official-Release' or 'Pre-Release'. It won't push the package to PyPI if it's 'Pre-Release'. |
| push-to-PyPI | string | Optional, Default value is _empty string_ | Push Python package to official PyPI or test PyPI. It has 2 type options: 'official' or 'test'. |

_Secret option_:

| option name | option is optional or required | function content |
|-------------|--------------------------------|-----------------------------|
| PyPI_user | Required | The username of PyPI. |
| PyPI_token | Required | The password token of PyPI. |

* Output:

No, nothing at all.

* How to use it?

```yaml
push_python_pkg_to_pypi:
# name: Upload the Python package files which has been compiled to PyPi
uses: ./.github/workflows/push_pkg_to_pypi.yaml
with:
release-type: 'Official-Release'
push-to-PyPI: test
secrets:
pypi_user: ${{ secrets.PYPI_USERNAME }}
pypi_token: ${{ secrets.PYPI_PASSWORD }}
```

2 changes: 1 addition & 1 deletion test_gh_workflow/__pkg_info__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.0-alpha1.post1"
__version__ = "0.2.0"