diff --git a/.github/workflows/build_git-tag_and_create_github-release.yaml b/.github/workflows/build_git-tag_and_create_github-release.yaml index f0e69f9b..625e52a9 100644 --- a/.github/workflows/build_git-tag_and_create_github-release.yaml +++ b/.github/workflows/build_git-tag_and_create_github-release.yaml @@ -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 diff --git a/.github/workflows/organize_and_generate_test_cov_reports.yaml b/.github/workflows/organize_and_generate_test_cov_reports.yaml index 264f7b9a..2637422b 100644 --- a/.github/workflows/organize_and_generate_test_cov_reports.yaml +++ b/.github/workflows/organize_and_generate_test_cov_reports.yaml @@ -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) diff --git a/.github/workflows/push_pkg_to_pypi.yaml b/.github/workflows/push_pkg_to_pypi.yaml new file mode 100644 index 00000000..248e74a1 --- /dev/null +++ b/.github/workflows/push_pkg_to_pypi.yaml @@ -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 }} diff --git a/.github/workflows/test_python_project_ci_one-test.yaml b/.github/workflows/test_python_project_ci_one-test.yaml index 0aa29973..94b20d92 100644 --- a/.github/workflows/test_python_project_ci_one-test.yaml +++ b/.github/workflows/test_python_project_ci_one-test.yaml @@ -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 }} diff --git a/.github/workflows/upload_test_cov_report.yaml b/.github/workflows/upload_test_cov_report.yaml index 92ee62b5..45e2ba16 100644 --- a/.github/workflows/upload_test_cov_report.yaml +++ b/.github/workflows/upload_test_cov_report.yaml @@ -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: | diff --git a/README.md b/README.md index 48bad357..a6e3ee60 100644 --- a/README.md +++ b/README.md @@ -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)