Skip to content

Commit

Permalink
Update deploy-pre-release.yml to handle " given by: --- name: Deploy …
Browse files Browse the repository at this point in the history
…Pre-Release Artifacts on: push: branches: - develop defaults: run: shell: bash env: LANG: en_US.utf-8 LC_ALL: en_US.utf-8 jobs: bump_version: runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: python-version: [ '3.8', '3.9', '3.10' ] # 3.11+ not suppport 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/[email protected] with: submodules: recursive fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} id: setup-python uses: actions/[email protected] 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: Bump version 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) 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} 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' with: artifacts: "dist/*.whl" artifactErrorsFailBuild: true generateReleaseNotes: true commit: ${{ github.ref }} prerelease: true tag: ${{ env.NEW_TAG }} token: ${{ secrets.GITHUB_TOKEN }} - name: Publish pre-release to pypi uses: pypa/gh-action-pypi-publish@release/v1 if: github.repository_owner == 'VOLTTRON' with: password: ${{ secrets.PYPI_TOKEN}}"
  • Loading branch information
kefeimo authored Nov 14, 2024
1 parent ec86c06 commit ca8628d
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions .github/workflows/deploy-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,73 +20,57 @@ 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/[email protected]
with:
submodules: recursive
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/[email protected]
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
Expand All @@ -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 }}

0 comments on commit ca8628d

Please sign in to comment.