diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 000000000..53877fe91 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,105 @@ +# Single workflow to increment ersilia version in pyproject.toml, +# tag and push the commit to the repository, release to GitHub, PyPI, Conda, and DockerHub + +name: Ersilia Release + +on: + workflow_dispatch: # run manually + schedule: + - cron: ' 0 3 1 * *' # run at 3:00 AM on the first day of the month + +jobs: + version: + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.version.outputs.VERSION }} + steps: + + - name: Checkout persist credentials + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v3.5.3 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + + - name: Increment package version + id: version + run: | + wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/.github/scripts/static_version_writer.py + echo "VERSION=$(python static_version_writer.py)" >> "$GITHUB_OUTPUT" + rm static_version_writer.py + + - name: Create a release tag + id: tag + run: | + git config --local user.email "ersilia-bot@users.noreply.github.com" + git config --local user.name "ersilia-bot" + git tag -a "v${{ steps.version.outputs.VERSION }}" -m "v${{ steps.version.outputs.VERSION }}" + + - name: Commit and push changes done to the static version file and pyproject.toml + uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # pin@v1.5 + with: + author_name: "ersilia-bot" + author_email: "ersilia-bot@users.noreply.github.com" + message: "update version [skip ci]" + repository: "ersilia-os/${{ github.event.repository.name }}" + github_token: ${{ secrets.GITHUB_TOKEN }} + amend: true + force: true + branch: "master" + + gh-release: + runs-on: ubuntu-latest + needs: version + steps: + + - name: Get Month + id: month + run: | + echo "MONTH=$(date +'%B')" >> $GITHUB_OUTPUT + + - name: Get Year + id: year + run: | + echo "YEAR=$(date +'%Y')" >> $GITHUB_OUTPUT + + - name: Release Title + id: title + run: | + echo "TITLE=${{ steps.month.outputs.MONTH }} ${{ steps.year.outputs.YEAR }}" >> $GITHUB_OUTPUT + + - name: Create GitHub release + id: gh_release + run: | + pip install gh + gh release create "v${{ needs.jobs.version.outputs.VERSION }}" --title "v${{ steps.title.outputs.TITLE }}" --notes-from-tag + + pypi-release: + runs-on: ubuntu-latest + needs: version + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v3.5.3 + + - name: Set up Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # pin@v5.1.0 + with: + python-version: '3.7' + # cache: 'pip' # caching pip dependencies + + - name: Get version + run: | + wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/ersilia/_static_version.py + mv _static_version.py ersilia/. + + - name: Python Poetry Action + uses: abatilo/actions-poetry@v3.0.0 + + - name: Build and publish + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + run: | + poetry config -- http-basic.pypi $PYPI_USERNAME $PYPI_PASSWORD + poetry --build publish + + diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index ef08b8ad0..000000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package - -on: - workflow_run: - workflows: ["Tag to version"] - types: - - completed - - workflow_dispatch: - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v3.5.3 - - - name: Set up Python - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # pin@v5.1.0 - with: - python-version: '3.7' - # cache: 'pip' # caching pip dependencies - - - name: Get version - run: | - wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/ersilia/_static_version.py - mv _static_version.py ersilia/. - - - name: Python Poetry Action - uses: abatilo/actions-poetry@v3.0.0 - - - name: Build and publish - env: - PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - - run: | - poetry config -- http-basic.pypi $PYPI_USERNAME $PYPI_PASSWORD - poetry --build publish diff --git a/.github/workflows/tag-to-version.yml b/.github/workflows/tag-to-version.yml deleted file mode 100644 index 0793ca57b..000000000 --- a/.github/workflows/tag-to-version.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Tag to version - -on: - push: - tags: - - 'v*' - - workflow_dispatch: - -jobs: - version: - runs-on: ubuntu-latest - - steps: - - name: Checkout persist credentials - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v3.5.3 - with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo - - - name: Make a change and commit - run: | - wget https://raw.githubusercontent.com/ersilia-os/ersilia/master/.github/scripts/static_version_writer.py - python static_version_writer.py - rm static_version_writer.py - - - name: Commit and push changes done to the static version file - uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # pin@v1.5 - with: - author_name: "ersilia-bot" - author_email: "ersilia-bot@users.noreply.github.com" - message: "update version [skip ci]" - repository: "ersilia-os/${{ github.event.repository.name }}" - github_token: ${{ secrets.GITHUB_TOKEN }} - amend: true - force: true - branch: "master" diff --git a/ersilia/_version.py b/ersilia/_version.py index c44df9863..9690b6ce2 100644 --- a/ersilia/_version.py +++ b/ersilia/_version.py @@ -33,9 +33,14 @@ def get_latest_semver_tag(): return tag return None +def increment_patch_version(version): + version = version.split(".") + version[2] = str(int(version[2]) + 1) + return ".".join(version) def get_version_for_setup(): - version = get_latest_semver_tag() + # version = get_latest_semver_tag() + version = increment_patch_version(get_version_from_static()) with open(os.path.join(root, STATIC_VERSION_FILE), "w") as f: f.write('version = "{0}"\n'.format(version)) return version