From 5aa7199dca21af7d548ca31599c02ba418f2acd4 Mon Sep 17 00:00:00 2001 From: "C. Allwardt" <3979063+craig8@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:20:37 -0700 Subject: [PATCH 1/3] Updated deploy-dev-release --- .github/workflows/deploy-dev-release.yml | 179 ++++++++++------------- 1 file changed, 78 insertions(+), 101 deletions(-) diff --git a/.github/workflows/deploy-dev-release.yml b/.github/workflows/deploy-dev-release.yml index 65939b9..66ae989 100644 --- a/.github/workflows/deploy-dev-release.yml +++ b/.github/workflows/deploy-dev-release.yml @@ -1,3 +1,14 @@ +######################################################################################################## +# Deploys a develop release and commits pyproject.toml files with new versions. +# +# When will it run: +# This workflow will only run on push to develop when there is a python file change. +# +# How will it update: +# The script should update based upon the current version in the pyproject.toml file. The workflow +# should run poetry version prerelease to create a new version file. Since this +# repository houses multiple wheels we will be using the ./scripts/runoneach.sh to run this command. +######################################################################################################## name: Deploy Dev Release Artifacts on: @@ -6,11 +17,11 @@ on: - develop workflow_dispatch: inputs: - release-version: - description: "Version number to use. If provided bump-rule will be ignored" + upgrade-version: + description: "Upgrade version number regardless of whether a py file is altered." required: false - default: "" - type: string + default: false + type: boolean defaults: run: @@ -31,20 +42,54 @@ jobs: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - + - run: echo "The specified version is ${{ inputs.release-version }}." + - run: | + set -x + set -u + set -e #---------------------------------------------- # check-out repo and set-up python #---------------------------------------------- - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # ref: develop token: ${{ secrets.GITHUB_TOKEN }} + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v45 + # To compare changes between the current commit and the last pushed remote commit set `since_last_remote_commit: true`. e.g + # with: + # since_last_remote_commit: true + with: + files: | + **.py + + - name: Should change version + id: should_update_version + env: + PYTHON_FILES_CHANGED: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + should_update=false + for file in ${PYTHON_FILES_CHANGED}; do + should_update=true + break + done + + # handle input required update. + if ${{ inputs.upgrade-version }} ; then + should_update=true + fi + + echo "Should update == ${should_update}" + echo "value=${should_update}" >> "$GITHUB_OUTPUT" + - name: Set up Python ${{ env.PYTHON_VERSION }} + if: ${{ steps.should_update_version.outputs.value == 'true' }} id: setup-python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} @@ -52,109 +97,44 @@ jobs: # ----- install & configure poetry ----- #---------------------------------------------- - name: Install Poetry - uses: snok/install-poetry@v1.3.3 + if: ${{ steps.should_update_version.outputs.value == 'true' }} + uses: snok/install-poetry@v1 with: virtualenvs-create: true virtualenvs-in-project: true installer-parallel: true - # #---------------------------------------------- - # # load cached venv if cache exists - # #---------------------------------------------- - # - name: Load cached venv - # id: cached-poetry-dependencies - # uses: actions/cache@v3 - # with: - # path: .venv - # key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} - - # #---------------------------------------------- - # # install dependencies if cache does not exist - # #---------------------------------------------- - # - name: Install dependencies - # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - # run: poetry install --no-interaction --no-root + - name: Update version and commit pyproject.toml file + if: ${{ steps.should_update_version.outputs.value == 'true' }} + run: | + ./scripts/run_on_each.sh poetry version prerelease + + git config --global user.name 'Commit Bot' + git config --global user.email '3979063+craig8@users.noreply.github.com' + git add **/pyproject.toml + git commit -m "Auto Update Version Number" + git push - #---------------------------------------------- - # install your root project, if required - #---------------------------------------------- - name: Install library - run: | + if: ${{ steps.should_update_version.outputs.value == 'true' }} + run: | ./scripts/poetry_install.sh - # git checkout develop - # poetry lock --no-update - # poetry install --no-interaction - - # - name: Use given release-version number - # if: inputs.release-version != '' - # run: | - # echo "Using given release version is ${{ inputs.release-version }}" - # poetry version ${{ inputs.release-version }} - - # NEW_TAG=v$(poetry version --short) - - # # we want to be able to use the variable in later - # # steps we set a NEW_TAG environmental variable - # echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV - # # we don't want to update pyproject.toml yet. don't want this change to create merge conflict. - # # we don't really persist right version in pyproject.toml to figure out the next version. we use git tags. - # git restore pyproject.toml - - #---------------------------------------------- - # bump version number for patch - #---------------------------------------------- - - name: Bump Version - run: | - # current_tag is the last tagged release in the repository. From there - # we need to remove the v from the beginning of the tag. - # echo "Bump rule is ${{ inputs.bump-rule }}" - # echo "Given release version is ${{ inputs.release-version }}" - # dt=$(date +%Y.%-m.0) - # if ! $(git tag -l "v*" = ''); then - # # uses -V which is version sort to keep it monotonically increasing. - # current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) - # echo "current git tag is ${current_tag}" - # current_tag=${current_tag#?} - # if [[ "$current_tag" < "$dt" ]]; then - # current_tag=$dt - # fi - # # current_tag is now the version we want to set our poetry version so - # # that we can bump the version - # ./scripts/run_on_each.sh poetry version ${current_tag} - # ./scripts/run_on_each.sh poetry version prerelease - - # # poetry version ${current_tag} - # # poetry version prerelease --no-interaction - - # else - # # very first release. start with inputs.release-version - - # echo "First release. Setting tag as 0.1.0rc0" - # current_tag=$(date +%Y.%-m.1) - # ./scripts/run_on_each.sh poetry version ${current_tag} - - # # poetry version ${current_tag} - # fi - version=$(poetry version --short) - ./scripts/run_on_each.sh poetry version ${version} - - NEW_TAG=v$(poetry version --short) - - # Finally because we want to be able to use the variable in later - # steps we set a NEW_TAG environmental variable - echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV - - name: Create build artifacts + id: version + if: ${{ steps.should_update_version.outputs.value == 'true' }} run: | - set -x - set -u - set -e - # set the right version in pyproject.toml before build and publish ./scripts/poetry_build.sh + + echo "value=v$(poetry version --short)" >> "$GITHUB_OUTPUT" + + # TODO: Check for pipy token and only release to github if we have it. - name: Push artifacts to github + env: + TAG: ${{ steps.version.outputs.value }} + if: ${{ steps.should_update_version.outputs.value == 'true' }} uses: ncipollo/release-action@v1 with: artifacts: "dist/*.gz,dist/*.whl" @@ -163,17 +143,14 @@ jobs: commit: ${{ github.ref }} # check bump-rule and set accordingly prerelease: true - tag: ${{ env.NEW_TAG }} + tag: ${{ env.TAG }} token: ${{ secrets.GITHUB_TOKEN }} - name: Publish to pypi id: publish-to-pypi - if: github.repository_owner == 'GRIDAPPSD' || github.repository_owner == 'PNNL-CIM-Tools' + if: ${{ steps.should_update_version.outputs.value == 'true' }} run: | - set -x - set -u - set -e - + # This is needed, because the poetry publish will fail at the top level of the project # so ./scripts/run_on_each.sh fails for that. echo "POETRY_PUBLISH_OPTIONS=''" >> $GITHUB_ENV From ace0bd1b200e137902407115eb9d4bc5aca6b4ff Mon Sep 17 00:00:00 2001 From: "C. Allwardt" <3979063+craig8@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:23:36 -0800 Subject: [PATCH 2/3] Update gridappsd-field-bus-lib to 2025.2.1 --- gridappsd-field-bus-lib/pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gridappsd-field-bus-lib/pyproject.toml b/gridappsd-field-bus-lib/pyproject.toml index 9aa33bd..12a90e0 100644 --- a/gridappsd-field-bus-lib/pyproject.toml +++ b/gridappsd-field-bus-lib/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gridappsd-field-bus" -version = "2024.12.0.a1" +version = "2025.2.1" description = "GridAPPS-D Field Bus Implementation" authors = [ "C. Allwardt <3979063+craig8@users.noreply.github.com>", @@ -24,8 +24,8 @@ packages = [ [tool.poetry.dependencies] python = ">=3.10,<4.0" -gridappsd-python = { path="../gridappsd-python-lib", develop = true} -cim-graph = ">=0.1.1a0" +gridappsd-python = "^2025.2.1" +cim-graph = "^0.1.8a0" click = "^8.1.8" [tool.poetry.scripts] @@ -43,7 +43,7 @@ yapf = "^0.32.0" pre-commit = "^4.1.0" [build-system] -requires = ["poetry-core>=1.2.0"] +requires = ["poetry-core>=2.0.0"] build-backend = "poetry.core.masonry.api" [tool.yapfignore] From 8d29b70b138bda4663a2d48fca26a246a132d9fd Mon Sep 17 00:00:00 2001 From: "C. Allwardt" <3979063+craig8@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:29:50 -0800 Subject: [PATCH 3/3] reset to use path in pyproject.toml --- gridappsd-field-bus-lib/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gridappsd-field-bus-lib/pyproject.toml b/gridappsd-field-bus-lib/pyproject.toml index 12a90e0..e9aa64d 100644 --- a/gridappsd-field-bus-lib/pyproject.toml +++ b/gridappsd-field-bus-lib/pyproject.toml @@ -24,7 +24,7 @@ packages = [ [tool.poetry.dependencies] python = ">=3.10,<4.0" -gridappsd-python = "^2025.2.1" +gridappsd-python = { path="../gridappsd-python-lib", develop = true} cim-graph = "^0.1.8a0" click = "^8.1.8"