From 70dde371574592387976949570e41d40c2eb5474 Mon Sep 17 00:00:00 2001 From: Shahar Bar <33932594+shaharbar1@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:28:40 +0300 Subject: [PATCH] Fix CD version reference (#58) ### Changes * Updated package Version to 0.5.1 on pyproject.toml. * Updated continuous_delivery.yml to handle the version correctly. --- .github/workflows/continuous_delivery.yml | 27 ++++++++++++----------- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/continuous_delivery.yml b/.github/workflows/continuous_delivery.yml index b16db89..73bbf30 100644 --- a/.github/workflows/continuous_delivery.yml +++ b/.github/workflows/continuous_delivery.yml @@ -46,28 +46,24 @@ jobs: run: | if [ $(git tag -l "${{ env.PACKAGE_VERSION }}") ]; then echo "Version ${{ env.PACKAGE_VERSION }} already exists." - exit 0 + echo "VERSION_CHANGED=false" >> $GITHUB_ENV + else + echo "VERSION_CHANGED=true" >> $GITHUB_ENV fi - - name: Build and publish to pypi - if: ${{ success() && matrix.python-version == 3.8 }} - run: | - poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} - poetry publish --build - name: Create a Git tag - if: ${{ success() && matrix.python-version == 3.8 }} + if: ${{ env.VERSION_CHANGED == 'true' && matrix.python-version == '3.8' }} run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "GitHub Actions" git tag "${{ env.PACKAGE_VERSION }}" git push origin "${{ env.PACKAGE_VERSION }}" - name: Publish Draft Release - if: ${{ success() && matrix.python-version == 3.8 }} + if: ${{ env.VERSION_CHANGED == 'true' && matrix.python-version == '3.8' }} uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} - package-version: ${{ env.PACKAGE_VERSION }} script: | - const { data: releases } = await github.repos.listReleases({ + const { data: releases } = await github.rest.repos.listReleases({ owner: context.repo.owner, repo: context.repo.repo, }); @@ -75,14 +71,19 @@ jobs: const draftRelease = releases.find(r => r.draft && r.name === 'Draft'); if (draftRelease) { - await github.repos.updateRelease({ + await github.rest.repos.updateRelease({ owner: context.repo.owner, repo: context.repo.repo, release_id: draftRelease.id, - tag_name: package-version, - name: package-version, + tag_name: process.env.PACKAGE_VERSION, + name: process.env.PACKAGE_VERSION, draft: false }); } else { core.setFailed(`Draft release named "Draft" not found.`); }; + - name: Build and publish to pypi + if: ${{ env.VERSION_CHANGED == 'true' && matrix.python-version == '3.8' }} + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish --build diff --git a/pyproject.toml b/pyproject.toml index 912d75d..565164e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybandits" -version = "0.5.0" +version = "0.5.1" description = "Python Multi-Armed Bandit Library" authors = [ "Dario d'Andrea ",