Skip to content

Commit

Permalink
Move deb pkg version stuff to separate script
Browse files Browse the repository at this point in the history
  • Loading branch information
kepstin committed Mar 5, 2023
1 parent c0653a3 commit e898329
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,7 @@ jobs:
UBUNTU_VERSION: ${{ matrix.UBUNTU_VERSION }}
run: |
cd source
DPKG_VERSION=$(dpkg-parsechangelog -S version)
DPKG_DISTRIBUTION=$(dpkg-parsechangelog -S distribution)
GIT_SEPARATOR='+'
DCH_BACKPORT=
if [[ $DPKG_DISTRIBUTION == UNRELEASED ]]; then
GIT_SEPARATOR='~0+'
elif [[ $DPKG_DISTRIBUTION != $UBUNTU_CODENAME ]]; then
DCH_BACKPORT="~$UBUNTU_VERSION"
fi
GIT_DESCRIBE=$(git describe --tags)
GIT_TAG=$(git describe --tags --abbrev=0)
GIT_EXTRA=${GIT_DESCRIBE#${GIT_TAG}}
GIT_EXTRA=${GIT_EXTRA/-/$GIT_SEPARATOR}
GIT_EXTRA=${GIT_EXTRA//-/.}
DCH_VERSION="${DPKG_VERSION}${DCH_BACKPORT}${GIT_EXTRA}"
echo "DCH_VERSION=${DCH_VERSION}" | tee -a $GITHUB_ENV
eval "$(./dch_version.sh | tee -a "${GITHUB_ENV}")"
dch --newversion "${DCH_VERSION}" --force-bad-version --distribution "${UBUNTU_CODENAME}" "Automatic Build"
- name: Cleanup .github directory
Expand Down
30 changes: 30 additions & 0 deletions dch_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# This is a tool to convert a semver 2.0.0 compatible version to a format which
# is compatible with both debian packaging tools and - after the transformations
# applied in debian pybuild - python PEP 440. It should generate the same python
# package version as is generated by setuptools_scm's "post-release" scheme.
GIT_TAG=$(git describe --tags --abbrev=0 "$@")
GIT_DESCRIBE=$(git describe --tags --long --dirty=.d$(date +%Y%m%d) "$@")
GIT_EXTRA="${GIT_DESCRIBE#${GIT_TAG}}"
GIT_TAG="${GIT_TAG//-/'~'}"
GIT_TAG="${GIT_TAG//alpha./alpha}"
GIT_TAG="${GIT_TAG//beta./beta}"
GIT_TAG="${GIT_TAG//rc./rc}"
DCH_VERSION="${GIT_TAG}"

GIT_EXTRA="${GIT_EXTRA#-}"
GIT_DISTANCE="${GIT_EXTRA%%-*}"
GIT_BUILD="${GIT_EXTRA#${GIT_DISTANCE}-}"
GIT_BUILD_HASH="${GIT_BUILD%%.*}"
if [[ $GIT_DISTANCE == 0 ]]; then
GIT_BUILD="${GIT_BUILD#${GIT_BUILD_HASH}}"
GIT_BUILD="${GIT_BUILD#.}"
fi
if [[ -n $GIT_BUILD ]]; then
DCH_VERSION+=".post${GIT_DISTANCE}+${GIT_BUILD}"
elif [[ $GIT_DISTANCE != 0 ]]; then
DCH_VERSION+=".post${GIT_DISTANCE}"
fi

echo "DCH_VERSION=${DCH_VERSION@Q}"

0 comments on commit e898329

Please sign in to comment.