Skip to content

Update build-and-publish-TestPyPI-dummy.yml #26

Update build-and-publish-TestPyPI-dummy.yml

Update build-and-publish-TestPyPI-dummy.yml #26

# This workflow will increment version patch number, cherry pick this new version to dev,
# and build and publish the package to TestPyPI upon push or merge to staging branch
name: Staging Dummy Publish
on:
push:
branches:
- 'staging-dummy'
# needed to stop endless commit loop by auto-bump
paths-ignore:
- setup.py
- .bumpversion.cfg
jobs:
publish:
name: Staging Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# cut assumes version number is surrounded by double-quotes.
- name: Get Current Version
run: echo "current_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Auto Bump Package Version
uses: FragileTech/bump-version@main
with:
current_version: "${{ env.current_version }}"
files: setup.py
part: patch
commit_name: bot-edgepi
commit_email: bot@edgepi.com
login: bot-edgepi
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
# - name: Set up Python
# uses: actions/setup-python@v3
# with:
# python-version: '3.10'
# - name: Install Dependencies
# run: |
# python -m pip install --upgrade pip
# if [ -f requirements_build.txt ]; then python -m pip install -r requirements_build.txt; fi
# - name: Build Package
# run: |
# python -m build
# - name: Publish Distribution to TestPyPI
# uses: pypa/gh-action-pypi-publish@v1.9.0
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
Hardware_Test:
needs: publish
name: Hardware Tests
runs-on: ubuntu-latest
# runs-on: [self-hosted, linux, ARM64, hw-test]
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: staging
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
- run: git pull
- name: Install Dependencies and check SDK versions
run: |
python -m venv venv_hardware_test
source venv_hardware_test/bin/activate
python -m pip install --upgrade pip
python -m pip install pytest
if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
echo "actual_sdk_version=$(pip list | grep edgepi | cut -d ' ' -f2)" >> $GITHUB_ENV
echo "expected_sdk_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Compare versions
run: |
if [ ${{env.expected_sdk_version}} != ${{env.actual_sdk_version}} ]; then
echo "SDK Version Mismatch"
exit 1
fi
# - name: Test with pytest
# run: |
# source venv_hardware_test/bin/activate
# python -m pytest ./tests/hardware_tests
- name: Handling Failure Get Version
if: failure()
run: |
# current_version should be changed to something else. the new version should be compared to the current version from previous step and revert if it was incremented.
echo "current_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
echo $current_version
- name: Handling Failure Delete tag
env:
commit_name: bot-edgepi
commit_email: bot@edgepi.com
login: bot-edgepi
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
run: |
set -x
# Setup Git env and user
git config user.name ${{ env.commit_name }}
git config user.email ${{ env.commit_email }}
git config --global pull.rebase false
BRANCH=${GITHUB_REF#refs/heads/}
git remote add ${{ env.login }} https://${{ env.login }}:${{ env.token }}@github.com/$GITHUB_REPOSITORY
git pull --no-edit ${{ env.login }} $BRANCH
git config --global url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf "https://github.com/"
# merge done by git pull does not update submodules changed in $BRANCH
git submodule update --init --recursive
# # Delete Git tags
# git tag -d rc/v$current_version
# git push origin --delete rc/v$current_version
# git config --global --unset url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf
# # Decrementing the current version number
# my_var=$(echo $(grep "version" setup.py | cut -d '"' -f2 | cut -d '.' -f3))
# echo $((my_var-1))
# # Write the reverted version number back to setup file and
# sed -i "s/\(version=\"[0-9]\+\.[0-9]\+\.\)[0-9]\+\"/\1$my_var\"/" setup.py
# sed -i "s/\(current_version = [0-9]\+\.[0-9]\+\.\)[0-9]\+/\1$my_var/" .bumpversion.cfg
Bump_version_on_dev:
name: Bump version numbers in Dev
needs: Hardware_Test
runs-on: ubuntu-latest
steps:
- name: Checkout Dev
uses: actions/checkout@v3
with:
ref: dev-dummy
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
- name: Auto Bump Commit SHA
run: |
echo "bump_commit=$(git log -n 1 origin/staging --pretty=format:'%H')" >> $GITHUB_ENV
# - name: Cherry Pick
# env:
# commit_name: bot-edgepi
# commit_email: bot@edgepi.com
# run: |
# echo ${{ env.bump_commit }}
# git config user.name ${{ env.commit_name }}
# git config user.email ${{ env.commit_email }}
# git cherry-pick ${{ env.bump_commit }}
# git push origin dev