From e6df45f9c1eb4d97f0bfc8f4a6a1c18d8a139a3f Mon Sep 17 00:00:00 2001 From: Craig <3979063+craig8@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:48:34 +0000 Subject: [PATCH 1/4] Add release package for releasing real releases --- .github/workflows/release.yml | 148 ++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d1618a0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,148 @@ +name: Deploy Release Artifacts + +on: + workflow_dispatch: + inputs: + previous-version: + description: "Previous version number to use for release notes generation." + required: true + type: bool + release-version: + description: "Version number to use for this release, do not start with v." + required: true + type: bool + publish-to: + description: "Publish to pypi or pypi-test" + required: true + type: string + default: "pypi" + options: + - "pypi" + - "pypi-test" + +defaults: + run: + shell: bash + +env: + LANG: en_US.utf-8 + LC_ALL: en_US.utf-8 + PYTHON_VERSION: "3.10" + +jobs: + deploy-release: + runs-on: ubuntu-22.04 + permissions: + contents: write # To push a branch + pull-requests: write # To create a PR from that branch + steps: + - 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 }}." + + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + # ref: develop + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python ${{ env.PYTHON_VERSION }} + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1.3.3 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: | + ./scripts/poetry_install.sh + + #---------------------------------------------- + # Update to new release version + #---------------------------------------------- + - name: Update Version + run: | + ./scripts/run_on_each.sh poetry version ${{ inputs.release-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 + run: | + set -x + set -u + set -e + + # set the right version in pyproject.toml before build and publish + ./scripts/poetry_build.sh + + - name: Push artifacts to github + # if: inputs.publish-to == 'pypi' + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*.gz,dist/*.whl" + artifactErrorsFailBuild: true + generateReleaseNotes: true + commit: ${{ github.ref }} + makeLatest: true + tag: ${{ env.NEW_TAG }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to pypi + id: publish-to-pypi + if: github.repository_owner == 'GRIDAPPSD' || github.repository_owner == 'PNNL-CIM-Tools' + 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 + cd gridappsd-python-lib + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish + + cd ../gridappsd-field-bus-lib + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish + + - name: Publish to pypi test + id: publish-to-pypi-test + if: inputs.publish-to == 'pypi-test' + run: | + set -x + set -u + set -e + + ./scripts/run_on_each.sh poetry config repositories.testpypi https://test.pypi.org/legacy/ + + # 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='--repository testpypi'" >> $GITHUB_ENV + cd gridappsd-python-lib + poetry config pypi-token.pypi ${{ secrets.PYPI_TEST_TOKEN }} + poetry publish + + cd ../gridappsd-field-bus-lib + poetry config pypi-token.pypi ${{ secrets.PYPI_TEST_TOKEN }} + poetry publish \ No newline at end of file From 740e9cd1935ee927364d4b18d40d24e405553ef0 Mon Sep 17 00:00:00 2001 From: Craig <3979063+craig8@users.noreply.github.com> Date: Tue, 6 Jun 2023 16:53:48 +0000 Subject: [PATCH 2/4] fix choice input for action --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1618a0..1eba0aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ on: publish-to: description: "Publish to pypi or pypi-test" required: true - type: string + type: choice default: "pypi" options: - "pypi" From 3a6116422bef8e961567a061eaec4250fc91e53d Mon Sep 17 00:00:00 2001 From: Craig <3979063+craig8@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:03:06 +0000 Subject: [PATCH 3/4] Fix pypi-token name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1eba0aa..c721c72 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,9 +140,9 @@ jobs: # so ./scripts/run_on_each.sh fails for that. echo "POETRY_PUBLISH_OPTIONS='--repository testpypi'" >> $GITHUB_ENV cd gridappsd-python-lib - poetry config pypi-token.pypi ${{ secrets.PYPI_TEST_TOKEN }} + poetry config pypi-token.testpypi ${{ secrets.PYPI_TEST_TOKEN }} poetry publish cd ../gridappsd-field-bus-lib - poetry config pypi-token.pypi ${{ secrets.PYPI_TEST_TOKEN }} + poetry config pypi-token.testpypi ${{ secrets.PYPI_TEST_TOKEN }} poetry publish \ No newline at end of file From 37b84649130289bee319b100bb260c7a66808fec Mon Sep 17 00:00:00 2001 From: Craig <3979063+craig8@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:09:38 +0000 Subject: [PATCH 4/4] Remove if condition on publish artifacts to github. --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c721c72..dcdd084 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,7 +96,6 @@ jobs: ./scripts/poetry_build.sh - name: Push artifacts to github - # if: inputs.publish-to == 'pypi' uses: ncipollo/release-action@v1 with: artifacts: "dist/*.gz,dist/*.whl"