From 5ec610ea517ebe4dd3a14d8b20d330071f6cb8d7 Mon Sep 17 00:00:00 2001 From: wphyojpl <38299756+wphyojpl@users.noreply.github.com> Date: Tue, 17 Sep 2024 19:00:57 -0500 Subject: [PATCH] feat: merge into a single ci/cd (#30) --- .github/workflows/feature_pr.yml | 86 ++++++++++++++++++++++--- .github/workflows/release_pr_create.yml | 28 -------- .github/workflows/release_pr_merge.yml | 50 -------------- 3 files changed, 76 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/release_pr_create.yml delete mode 100644 .github/workflows/release_pr_merge.yml diff --git a/.github/workflows/feature_pr.yml b/.github/workflows/feature_pr.yml index 53c351f..cf5df32 100644 --- a/.github/workflows/feature_pr.yml +++ b/.github/workflows/feature_pr.yml @@ -1,4 +1,4 @@ -name: Feature PR Merge / PYPI +name: PR Merge / PYPI on: pull_request: types: [ closed ] @@ -20,34 +20,100 @@ jobs: with: python-version: '3.9' - - name: Log PR info - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) + - name: Develop -- Log PR info + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) && !(contains(github.event.pull_request.title, 'catchup from main')) run: | echo "${PR_TITLE} -- ${PR_NUMBER}" - - name: Update setup version - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) + - name: Develop -- Update setup version + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) && !(contains(github.event.pull_request.title, 'catchup from main')) run: | python3 "${GITHUB_WORKSPACE}/.ci/update_setup_version.py" FEATURE - - name: Run version commit script - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) + - name: Develop -- Run version commit script + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && !(contains(github.event.pull_request.title, 'update version + change log')) && !(contains(github.event.pull_request.title, 'catchup from main')) run: | chmod +x "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" - - name: Install dependencies + + + + + - name: MAIN -- Log PR info + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && (contains(github.event.pull_request.title, 'RELEASE')) + run: | + echo "${PR_TITLE} -- ${PR_NUMBER}" + + - name: MAIN -- Update setup version + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && (contains(github.event.pull_request.title, 'RELEASE')) + run: | + python3 "${GITHUB_WORKSPACE}/.ci/update_setup_version.py" RELEASE + + - name: MAIN -- Run version commit script + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && (contains(github.event.pull_request.title, 'RELEASE')) + run: | + chmod +x "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" + "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" main + + + + + + + + - name: Develop -- Install dependencies if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && contains(github.event.pull_request.title, 'update version + change log') run: | python3 -m pip install poetry twine - - name: Build the project + - name: Develop -- Build the project if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && contains(github.event.pull_request.title, 'update version + change log') run: | python3 -m poetry build - - name: Upload to PyPI + - name: Develop -- Upload to PyPI if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && contains(github.event.pull_request.title, 'update version + change log') run: | python3 -m twine upload --repository pypi dist/* + + + + - name: MAIN -- Install dependencies + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log') + run: | + python3 -m pip install poetry twine + + - name: MAIN -- Build the project + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log') + run: | + python3 -m poetry build + + - name: MAIN -- Upload to PyPI + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log') + run: | + python3 -m twine upload --repository pypi dist/* + + - name: MAIN -- Upload to PyPI + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log') + run: | + # make file runnable, might not be necessary + chmod +x "${GITHUB_WORKSPACE}/.ci/store_version.sh" + "${GITHUB_WORKSPACE}/.ci/store_version.sh" + + - name: MAIN -- Create Release + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log') + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: "v${{ env.software_version }}" + release_name: "Release v${{ env.software_version }} - ${{ github.ref }}" + body: | + Changes in this release: + ${{ github.event.head_commit.message }} + body_path: release.md + draft: false + prerelease: false \ No newline at end of file diff --git a/.github/workflows/release_pr_create.yml b/.github/workflows/release_pr_create.yml deleted file mode 100644 index cba82f0..0000000 --- a/.github/workflows/release_pr_create.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Release PR Create -on: - pull_request: - types: [ opened ] - branches: [ main ] - -env: - ARTIFACT_BASE_NAME: mdps-ds-lib - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: ${{ github.event.pull_request.title }} - GH_TOKEN: ${{ github.token }} -jobs: - if_pr_opened: - if: github.event.pull_request.merged == false && !(contains(github.event.pull_request.title, 'update version + change log')) - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - python-version: '3.9' - - run: | - echo "${PR_TITLE} -- ${PR_NUMBER}" - - run: | - python3 "${GITHUB_WORKSPACE}/.ci/update_setup_version.py" RELEASE - - run: | - chmod +x "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" - "${GITHUB_WORKSPACE}/.ci/update_version_commit.sh" main diff --git a/.github/workflows/release_pr_merge.yml b/.github/workflows/release_pr_merge.yml deleted file mode 100644 index 55aafc2..0000000 --- a/.github/workflows/release_pr_merge.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Release PR PyPi -on: - pull_request: - types: [ closed ] - -env: - ARTIFACT_BASE_NAME: mdps-ds-lib - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: ${{ github.event.pull_request.title }} - GH_TOKEN: ${{ github.token }} - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - -jobs: - if_merged: - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && (contains(github.event.pull_request.title, 'update version + change log')) - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - with: - python-version: '3.9' - - run: | - python3 -m pip install poetry twine - - run: | - python3 -m poetry build - - run: | - python3 -m twine upload --repository pypi dist/* - - - run: | - # make file runnable, might not be necessary - chmod +x "${GITHUB_WORKSPACE}/.ci/store_version.sh" - "${GITHUB_WORKSPACE}/.ci/store_version.sh" - - - name: Create Release - id: create_release - if: ${{ contains(github.ref, 'master') }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: "v${{ env.software_version }}" - release_name: "Release v${{ env.software_version }} - ${{ github.ref }}" - body: | - Changes in this release: - ${{ github.event.head_commit.message }} - body_path: release.md - draft: false - prerelease: false \ No newline at end of file