Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 78 additions & 101 deletions .github/workflows/deploy-dev-release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -31,130 +42,99 @@ 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 }}

#----------------------------------------------
# ----- 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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gridappsd-field-bus-lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gridappsd-field-bus"
version = "2023.12.2a0"
version = "2024.8.1a0"
description = "GridAPPS-D Field Bus Implementation"
authors = [
"C. Allwardt <3979063+craig8@users.noreply.github.com>",
Expand Down
2 changes: 1 addition & 1 deletion gridappsd-python-lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gridappsd-python"
version = "2023.12.2a0"
version = "2024.8.1a0"
description = "A GridAPPS-D Python Adapter"
authors = [
"C. Allwardt <3979063+craig8@users.noreply.github.com>",
Expand Down
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 = "gridappsd-python-workspace"
version = "2024.6.0"
version = "2024.8.1a0"
description = "A GridAPPS-D Python Adapter"
authors = [
"C. Allwardt <3979063+craig8@users.noreply.github.com>",
Expand Down