Skip to content

Put back Update Version Number in python files #28

Put back Update Version Number in python files

Put back Update Version Number in python files #28

Workflow file for this run

---
name: Package
on: push
jobs:
Package_For_PIP:
strategy:
matrix:
platform: [ubuntu-latest]
python: ['3.x']
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: "Echo Vars"
run: |
echo matrix.platform: ${{ matrix.platform }}
echo matrix.python: ${{ matrix.python }}
- name: Git fetch
run: git fetch --prune --unshallow
- name: Get Branch Name
run: |
branchname=$(git rev-parse --abbrev-ref HEAD)
echo "branchname=$branchname" >> "$GITHUB_ENV"
- name: Get Current Release Tag
run: |
currrelease=$(git describe --abbrev=0 --tags)
echo "currrelease=$currrelease" >> "$GITHUB_ENV"
- name: Determine if this is a release branch
run: |
isrrelease=0
if [[ $branchname =~ v[0-9]\. ]]; then
isrrelease=1
fi
echo "isrrelease=$isrrelease" >> "$GITHUB_ENV"
- name: Determine if this is master branch
run: |
ismaster=0
if [[ $branchname == master ]]; then
ismaster=1
fi
echo "ismaster=$ismaster" >> "$GITHUB_ENV"
- name: Get Date String
if: ${{ env.isrrelease == 0 && env.ismaster == 0 }}
run: |
datestr=$(date +%Y%m%d%H%M%S)
echo "datestr=$datestr" >> "$GITHUB_ENV"
- name: Set Version Number to Branch Name
if: ${{ env.isrrelease == 1 }}
run: |
numver=$(echo "$branchname" | sed -E 's/v([^-]*)/\1/')
echo "numver=$numver" >> "$GITHUB_ENV"
version=v$numver
echo "version=$version" >> "$GITHUB_ENV"
- name: Set New Version Number
if: ${{ env.isrrelease == 0 && env.ismaster == 0 }}
run: |
numver=$(echo "$currrelease" | sed -E 's/v([^-]*)/\1/')
mapfile -d . -t numverparts < <(echo "$numver")
len=${#numverparts[@]}
if [ "$len" -gt "2" ]; then
numver=${numverparts[0]}.${numverparts[1]}.$(( numverparts[2] + 1))
elif [ "$len" -eq "2" ]; then
numver=${numverparts[0]}.${numverparts[1]}.1
else
numver=${numverparts[0]}.0.1
fi
numver=$numver.dev$datestr
echo "numver=$numver" >> "$GITHUB_ENV"
version=v$numver
echo "version=$version" >> "$GITHUB_ENV"
- name: "Echo Vars 2"
run: |
echo numver: ${{ env.numver }}
echo version: ${{ env.version }}
- name: Update Version Number in python files
run: |
cwd
sed -i -e "s/version = \"[^\"]*\"/version = \"${version}\"/" $(find . -name "*.py")
sed -i -e "s/# Version .*/# Version ${version}/" $(find . -name "*.py")
cat setup-manager.py
#