Standardize package building
1. Only build on GitLab when there's a tag. 2. Add the packages on GitLab to component "pvc" in the repo. 3. Add build-unstable-deb.sh script to build git-versioned packages. 4. Revamp build-and-deploy to use build-unstable-deb.sh and cut down on output.
This commit is contained in:
parent
78dec77987
commit
fc9df76570
|
@ -2,12 +2,14 @@ stages:
|
||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
build:
|
build_releases:
|
||||||
stage: build
|
stage: build
|
||||||
before_script:
|
before_script:
|
||||||
- git submodule update --init
|
- git submodule update --init
|
||||||
script:
|
script:
|
||||||
- /bin/bash build-deb.sh
|
- /bin/bash build-deb.sh
|
||||||
- /usr/local/bin/deploy-package
|
- /usr/local/bin/deploy-package -C pvc
|
||||||
only:
|
only:
|
||||||
- master
|
- tags
|
||||||
|
except:
|
||||||
|
- branches
|
||||||
|
|
|
@ -13,30 +13,35 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOSTS=( ${@} )
|
HOSTS=( ${@} )
|
||||||
echo "${HOSTS[@]}"
|
echo "> Deploying to host(s): ${HOSTS[@]}"
|
||||||
|
|
||||||
# Build the packages
|
# Build the packages
|
||||||
./build-deb.sh
|
echo -n "Building packages... "
|
||||||
|
version="$( ./build-unstable-deb.sh 2>/dev/null )"
|
||||||
|
echo "done. Package version ${version}."
|
||||||
|
|
||||||
# Install the client(s) locally
|
# Install the client(s) locally
|
||||||
$SUDO dpkg -i ../pvc-client*.deb
|
echo -n "Installing client packages locally... "
|
||||||
|
$SUDO dpkg -i ../pvc-client*_${version}*.deb &>/dev/null
|
||||||
|
echo "done".
|
||||||
|
|
||||||
for HOST in ${HOSTS[@]}; do
|
for HOST in ${HOSTS[@]}; do
|
||||||
echo "****"
|
echo "> Deploying packages to host ${HOST}"
|
||||||
echo "Deploying to host ${HOST}"
|
echo -n "Copying packages... "
|
||||||
echo "****"
|
ssh $HOST $SUDO rm -rf /tmp/pvc &>/dev/null
|
||||||
ssh $HOST $SUDO rm -rf /tmp/pvc
|
ssh $HOST mkdir /tmp/pvc &>/dev/null
|
||||||
ssh $HOST mkdir /tmp/pvc
|
scp ../pvc-*_${version}*.deb $HOST:/tmp/pvc/ &>/dev/null
|
||||||
scp ../*.deb $HOST:/tmp/pvc/
|
echo "done."
|
||||||
echo "Installing packages..."
|
echo -n "Installing packages... "
|
||||||
ssh $HOST $SUDO dpkg -i /tmp/pvc/{pvc-client-cli,pvc-daemon-common,pvc-daemon-api,pvc-daemon-node}*.deb
|
ssh $HOST $SUDO dpkg -i /tmp/pvc/{pvc-client-cli,pvc-daemon-common,pvc-daemon-api,pvc-daemon-node}*.deb &>/dev/null
|
||||||
ssh $HOST rm -rf /tmp/pvc
|
ssh $HOST rm -rf /tmp/pvc &>/dev/null
|
||||||
echo "Restarting PVC node daemon..."
|
echo "done."
|
||||||
ssh $HOST $SUDO systemctl restart pvcapid
|
echo -n "Restarting PVC daemons... "
|
||||||
ssh $HOST $SUDO systemctl restart pvcapid-worker
|
ssh $HOST $SUDO systemctl restart pvcapid &>/dev/null
|
||||||
ssh $HOST $SUDO systemctl restart pvcnoded
|
ssh $HOST $SUDO systemctl restart pvcapid-worker &>/dev/null
|
||||||
echo "****"
|
ssh $HOST $SUDO systemctl restart pvcnoded &>/dev/null
|
||||||
echo "Waiting 15s for host ${HOST} to stabilize"
|
echo "done."
|
||||||
echo "****"
|
echo -n "Waiting 15s for host to stabilize... "
|
||||||
sleep 15
|
sleep 15
|
||||||
|
echo "done."
|
||||||
done
|
done
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -o xtrace
|
||||||
|
exec 3>&1
|
||||||
|
exec 1>&2
|
||||||
|
# Ensure we're up to date
|
||||||
|
git pull --rebase
|
||||||
|
# Update the version to a sensible git revision for easy visualization
|
||||||
|
base_ver="$( head -1 debian/changelog | awk -F'[()-]' '{ print $2 }' )"
|
||||||
|
new_ver="${base_ver}~git-$(git rev-parse --short HEAD)"
|
||||||
|
echo ${new_ver} >&3
|
||||||
|
# Back up the existing changelog and Daemon.py files
|
||||||
|
tmpdir=$( mktemp -d )
|
||||||
|
cp -a debian/changelog node-daemon/pvcnoded/Daemon.py ${tmpdir}/
|
||||||
|
# Replace the "base" version with the git revision version
|
||||||
|
sed -i "s/version = '${base_ver}'/version = '${new_ver}'/" node-daemon/pvcnoded/Daemon.py
|
||||||
|
sed -i "s/${base_ver}-0/${new_ver}/" debian/changelog
|
||||||
|
cat <<EOF > debian/changelog
|
||||||
|
pvc (${new_ver}) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Unstable revision for commit $(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
-- Joshua Boniface <joshua@boniface.me> $( date -R )
|
||||||
|
EOF
|
||||||
|
# Build source tarball
|
||||||
|
dh_make -p pvc_${new_ver} --createorig --single --yes
|
||||||
|
# Build packages
|
||||||
|
dpkg-buildpackage -us -uc
|
||||||
|
# Restore original changelog and Daemon.py files
|
||||||
|
cp -a ${tmpdir}/changelog debian/changelog
|
||||||
|
cp -a ${tmpdir}/Daemon.py node-daemon/pvcnoded/Daemon.py
|
||||||
|
# Clean up
|
||||||
|
rm -r ${tmpdir}
|
||||||
|
dh_clean
|
Loading…
Reference in New Issue