From ca8628db28dd5714e51d5f905ea425bd945ccba5 Mon Sep 17 00:00:00 2001 From: kefeimo Date: Thu, 14 Nov 2024 10:16:38 -0600 Subject: [PATCH] =?UTF-8?q?Update=20deploy-pre-release.yml=20to=20handle?= =?UTF-8?q?=20"=20=20given=20by:=20=20---=20name:=20Deploy=20Pre-Release?= =?UTF-8?q?=20Artifacts=20=20on:=20=20=20push:=20=20=20=20=20branches:=20?= =?UTF-8?q?=20=20=20=20=20=20-=20develop=20=20defaults:=20=20=20run:=20=20?= =?UTF-8?q?=20=20=20shell:=20bash=20=20env:=20=20=20LANG:=20en=5FUS.utf-8?= =?UTF-8?q?=20=20=20LC=5FALL:=20en=5FUS.utf-8=20=20jobs:=20=20=20bump=5Fve?= =?UTF-8?q?rsion:=20=20=20=20=20runs-on:=20ubuntu-22.04=20=20=20=20=20stra?= =?UTF-8?q?tegy:=20=20=20=20=20=20=20fail-fast:=20false=20=20=20=20=20=20?= =?UTF-8?q?=20matrix:=20=20=20=20=20=20=20=20=20python-version:=20[=20'3.8?= =?UTF-8?q?',=20'3.9',=20'3.10'=20]=20=20#=203.11+=20not=20suppport=20=20?= =?UTF-8?q?=20=20=20steps:=20=20=20=20=20=20=20-=20run:=20echo=20"?= =?UTF-8?q?=F0=9F=8E=89=20The=20job=20was=20automatically=20triggered=20by?= =?UTF-8?q?=20a=20${{=20github.event=5Fname=20}}=20event."=20=20=20=20=20?= =?UTF-8?q?=20=20-=20run:=20echo=20"=F0=9F=90=A7=20This=20job=20is=20now?= =?UTF-8?q?=20running=20on=20a=20${{=20runner.os=20}}=20server=20hosted=20?= =?UTF-8?q?by=20GitHub!"=20=20=20=20=20=20=20-=20run:=20echo=20"?= =?UTF-8?q?=F0=9F=94=8E=20The=20name=20of=20your=20branch=20is=20${{=20git?= =?UTF-8?q?hub.ref=20}}=20and=20your=20repository=20is=20${{=20github.repo?= =?UTF-8?q?sitory=20}}."=20=20=20=20=20=20=20=20#-------------------------?= =?UTF-8?q?---------------------=20=20=20=20=20=20=20#=20=20=20=20=20=20?= =?UTF-8?q?=20check-out=20repo=20and=20set-up=20python=20=20=20=20=20=20?= =?UTF-8?q?=20#----------------------------------------------=20=20=20=20?= =?UTF-8?q?=20=20=20-=20name:=20Checkout=20code=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?uses:=20actions/checkout@v3.3.0=20=20=20=20=20=20=20=20=20with:?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20submodules:=20recursive=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20fetch-depth:=200=20=20=20=20=20=20?= =?UTF-8?q?=20=20-=20name:=20Set=20up=20Python=20${{=20matrix.python-versi?= =?UTF-8?q?on=20}}=20=20=20=20=20=20=20=20=20id:=20setup-python=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20uses:=20actions/setup-python@v4.5.0=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20with:=20=20=20=20=20=20=20=20=20=20=20python-?= =?UTF-8?q?version:=20${{=20matrix.python-version=20}}=20=20=20=20=20=20?= =?UTF-8?q?=20-=20run:=20echo=20"Installed=20python=20version=20$(python?= =?UTF-8?q?=20-V)"=20=20=20=20=20=20=20=20#-------------------------------?= =?UTF-8?q?---------------=20=20=20=20=20=20=20#=20install=20cmake=20to=20?= =?UTF-8?q?allow=20us=20to=20build=20the=20wheel=20=20=20=20=20=20=20#----?= =?UTF-8?q?------------------------------------------=20=20=20=20=20=20=20?= =?UTF-8?q?-=20name:=20Install=20Libraries=20=20=20=20=20=20=20=20=20run:?= =?UTF-8?q?=20|=20=20=20=20=20=20=20=20=20=20=20pip=20install=20cmake=20wh?= =?UTF-8?q?eel=20packaging=20=20=20=20=20=20=20-=20name:=20Bump=20version?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20run:=20|=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20#=20current=20version=20in=20the=20setup.py=20file=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20current=5Fversion=3D$(sed=20-n=20?= =?UTF-8?q?-e=20's/^.*=5F=5Fversion=5F=5F=20=3D=20//p'=20setup.py)=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20current=5Fversion=3D$(echo=20${curre?= =?UTF-8?q?nt=5Fversion}=20|=20sed=20-e=20"s/'//g")=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20#=20current=5Ftag=20is=20the=20last=20tagged=20rele?= =?UTF-8?q?se=20in=20the=20repository.=20=20=20From=20there=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20#=20we=20need=20to=20remove=20the=20v=20from?= =?UTF-8?q?=20the=20begining=20of=20the=20tag.=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20if=20!=20$(git=20tag=20-l=20"v*"=20=3D=20'');=20then=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20=20#=20uses=20-V=20which=20is?= =?UTF-8?q?=20version=20sort=20to=20keep=20it=20monotonically=20increasing?= =?UTF-8?q?.=20=20=20=20=20=20=20=20=20=20=20=20=20current=5Ftag=3D$(git?= =?UTF-8?q?=20tag=20-l=20"v*"=20|=20grep=20--invert-match=20'-'=20|=20sort?= =?UTF-8?q?=20--reverse=20-V=20=20|=20sed=20-n=201p)=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20else=20=20=20=20=20=20=20=20=20=20=20=20=20current?= =?UTF-8?q?=5Ftag=3Dv$current=5Fversion=20=20=20=20=20=20=20=20=20=20=20fi?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20=20current=5Ftag=3D${current=5Fta?= =?UTF-8?q?g#=3F}=20=20=20=20=20=20=20=20=20=20=20new=5Fversion=3D$(python?= =?UTF-8?q?=20.github/workflows/versions.py=20${current=5Ftag}=20--prerele?= =?UTF-8?q?ase)=20=20=20=20=20=20=20=20=20=20=20new=5Ftag=3Dv${new=5Fversi?= =?UTF-8?q?on}=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20sed=20-i=20"s/^.*-=5F=5Fversion=5F=5F=20=3D=20/=5F=5Fversion?= =?UTF-8?q?=5F=5F=20=3D=20$new=5Fversion/"=20setup.py=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20echo=20"New=20version=20is:=20${new=5Fversion}"=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20#=20Finally=20because=20we=20want?= =?UTF-8?q?=20to=20be=20able=20to=20use=20the=20variable=20in=20later=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20=20#=20steps=20we=20set=20a=20NEW=5F?= =?UTF-8?q?TAG=20environmental=20variable=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?echo=20"NEW=5FTAG=3D$(echo=20${new=5Ftag})"=20>>=20$GITHUB=5FEN?= =?UTF-8?q?V=20=20=20=20=20=20=20#----------------------------------------?= =?UTF-8?q?------=20=20=20=20=20=20=20#=20Build=20wheel=20=20=20=20=20=20?= =?UTF-8?q?=20#----------------------------------------------=20=20=20=20?= =?UTF-8?q?=20=20=20-=20name:=20Build=20wheel=20=20=20=20=20=20=20=20=20ru?= =?UTF-8?q?n:=20|=20=20=20=20=20=20=20=20=20=20=20python=20setup.py=20inst?= =?UTF-8?q?all=20=20=20=20=20=20=20=20=20=20=20python=20setup.py=20bdist?= =?UTF-8?q?=5Fwheel=20--plat-name=3Dmanylinux1=5Fx86=5F64=20=20=20=20=20?= =?UTF-8?q?=20=20-=20uses:=20ncipollo/release-action@v1=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20if:=20github.repository=5Fowner=20=3D=3D=20'VOLTTRON'?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20with:=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20artifacts:=20"dist/*.whl"=20=20=20=20=20=20=20=20=20=20=20ar?= =?UTF-8?q?tifactErrorsFailBuild:=20true=20=20=20=20=20=20=20=20=20=20=20g?= =?UTF-8?q?enerateReleaseNotes:=20true=20=20=20=20=20=20=20=20=20=20=20com?= =?UTF-8?q?mit:=20${{=20github.ref=20}}=20=20=20=20=20=20=20=20=20=20=20pr?= =?UTF-8?q?erelease:=20true=20=20=20=20=20=20=20=20=20=20=20tag:=20${{=20e?= =?UTF-8?q?nv.NEW=5FTAG=20}}=20=20=20=20=20=20=20=20=20=20=20token:=20${{?= =?UTF-8?q?=20secrets.GITHUB=5FTOKEN=20}}=20=20=20=20=20=20=20=20-=20name:?= =?UTF-8?q?=20Publish=20pre-release=20to=20pypi=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?uses:=20pypa/gh-action-pypi-publish@release/v1=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20if:=20github.repository=5Fowner=20=3D=3D=20'VOLTTRO?= =?UTF-8?q?N'=20=20=20=20=20=20=20=20=20with:=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20password:=20${{=20secrets.PYPI=5FTOKEN}}"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-pre-release.yml | 48 ++++++++---------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/.github/workflows/deploy-pre-release.yml b/.github/workflows/deploy-pre-release.yml index 942c6b8..cfaff7d 100644 --- a/.github/workflows/deploy-pre-release.yml +++ b/.github/workflows/deploy-pre-release.yml @@ -20,15 +20,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ '3.8', '3.9', '3.10' ] # 3.11+ not suppport + python-version: [ '3.8', '3.9', '3.10' ] # 3.11+ not supported 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.3.0 with: @@ -36,57 +33,44 @@ jobs: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - id: setup-python uses: actions/setup-python@v4.5.0 with: python-version: ${{ matrix.python-version }} - run: echo "Installed python version $(python -V)" - #---------------------------------------------- - # install cmake to allow us to build the wheel - #---------------------------------------------- - name: Install Libraries run: | pip install cmake wheel packaging + + - name: Fetch all tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Bump version + - name: Bump version and check tag + id: version_and_tag run: | - # current version in the setup.py file current_version=$(sed -n -e 's/^.*__version__ = //p' setup.py) current_version=$(echo ${current_version} | sed -e "s/'//g") - - # current_tag is the last tagged relese in the repository. From there - # we need to remove the v from the begining of the tag. 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) + current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) + current_tag=${current_tag#?} else current_tag=v$current_version fi - current_tag=${current_tag#?} - new_version=$(python .github/workflows/versions.py ${current_tag} --prerelease) + new_tag=v${new_version} + if git tag -l | grep -q "^${new_tag}$"; then + echo "Tag ${new_tag} already exists, incrementing..." + # Your logic to modify new_tag to make it unique + fi + echo "NEW_TAG=${new_tag}" >> $GITHUB_ENV - new_tag=v${new_version} - - sed -i "s/^.*-__version__ = /__version__ = $new_version/" setup.py - - echo "New version is: ${new_version}" - - # 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 - - #---------------------------------------------- - # Build wheel - #---------------------------------------------- - name: Build wheel run: | python setup.py install python setup.py bdist_wheel --plat-name=manylinux1_x86_64 - uses: ncipollo/release-action@v1 - if: github.repository_owner == 'VOLTTRON' + if: github.repository_owner == 'VOLTTRON' && env.NEW_TAG != '' with: artifacts: "dist/*.whl" artifactErrorsFailBuild: true @@ -100,4 +84,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 if: github.repository_owner == 'VOLTTRON' with: - password: ${{ secrets.PYPI_TOKEN}} + password: ${{ secrets.PYPI_TOKEN }}