Skip to content

Commit

Permalink
Fix CD version reference (#58)
Browse files Browse the repository at this point in the history
### Changes
 * Updated package Version to 0.5.1 on pyproject.toml.
 * Updated continuous_delivery.yml to handle the version correctly.
  • Loading branch information
shaharbar1 authored Sep 5, 2024
1 parent 78b98a9 commit 70dde37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/continuous_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,44 @@ 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,
});
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down

0 comments on commit 70dde37

Please sign in to comment.