Skip to content

Instantly share code, notes, and snippets.

@anonymouse64
Created August 28, 2021 02:16
Show Gist options
  • Save anonymouse64/ea5ae34f5efd4ab1e98f0819b6053014 to your computer and use it in GitHub Desktop.
Save anonymouse64/ea5ae34f5efd4ab1e98f0819b6053014 to your computer and use it in GitHub Desktop.
Release snapd prototype automated script
#!/bin/bash -e
# TODO: programatically figure these out
PREV_VERSION=2.51.6
NEW_VERSION=2.51.7
MAJOR_VERSION=2.51
IS_MINOR=1
RELEASE_BRANCH=release/$MAJOR_VERSION
BETA_RELEASE_BRANCH=beta/$MAJOR_VERSION
PERSONAL_FORK=ijohnson
LP_SRU_BUG=1929842
# checkout the release branch
git checkout "$RELEASE_BRANCH"
# generate the changelog
./snappy-dch.py "$PREV_VERSION" > "$NEW_VERSION-changelog.txt"
# edit the changelog as necessary
# TODO: figure out the LP bug automatically
# it's either the same LP bug for the previous release if this is a new minor
# version, or it's a new bug we have to file if this is a new major version
# do the packaging changes
./changelog.py "$NEW_VERSION" "$LP_SRU_BUG" "$NEW_VERSION-changelog.txt"
# TODO: double check that the right files are changed
# TODO: make a new branch and commit the packaging changes
# TODO: open a PR with the changelog available
# TODO: wait for that PR to be merged
# now that it's merged we can tag the release and push the tag
git tag -s "$NEW_VERSION"
# push the tag to origin
git push origin "$NEW_VERSION"
if [ "$IS_MINOR" = "1" ]; then
# TODO: trigger the code import for the LP release branch to trigger the
# snapd snap to start building using LP API
true
else
# TODO: create a new snap build recipe for the snapd snap using LP API
true
# TODO: create a new snap build recipe for the core snap using LP API
fi
# install package dependencies
sudo apt build-dep -y .
# build the package
gbp buildpackage -S --git-ignore-branch --git-no-purge --git-ignore-new
pushd ../build-area > /dev/null
# now push the source package
dput ppa:snappy-dev/image "snapd_${NEW_VERSION}_source.changes"
# generate the vendor tarballs for the github release page
../snapd/release-tools/repack-debian-tarball.sh "./snapd_$NEW_VERSION.tar.xz"
# build the focal version of the xenial package
pushd "snapd-$NEW_VERSION" > /dev/null
# change the packaging for focal to build the xenial source pkg
sed -i '0,/xenial/s//focal/' ./packaging/ubuntu-16.04/changelog
sed -i "0,/${NEW_VERSION}/s//${NEW_VERSION}+20.04/" ./packaging/ubuntu-16.04/changelog
dpkg-buildpackage -S
popd > /dev/null
# now push the focal source package
dput ppa:snappy-dev/image "snapd_${NEW_VERSION}+20.04_source.changes"
popd > /dev/null
# TODO: wait for the launchpad deb builds of snapd for focal and xenial to be
# successful, notify / retry as necessary if they fail
# TODO: trigger the beta core snap build after the deb builds are successful
# TODO: create the github release page and attach the vendor tarballs to the
# release
# wait until snapd snapd is built to the appropriate release branch off beta
# TODO: do this in a background thread or something
until [ "$(snapcraft status snapd | grep $BETA_RELEASE_BRANCH | awk '{print $2}' | sort | uniq)" = "$NEW_VERSION" ]; do
sleep 60
echo "waiting for snapd snap to be published to beta release branch"
done
# snapd snap is now built into $BETA_RELEASE_BRANCH, we can promote it to beta
# directly
# TODO: snapcraft complains that snapcraft promote is not ready for CLI usage yet :-/
# TODO: there's a --yes option here, don't use it yet
snapcraft promote snapd --from-channel="$BETA_RELEASE_BRANCH" --to-channel=beta
# TODO: also need to check on the core snap getting stuck in the review queue
# the core snap also builds into a $BETA_RELEASE_BRANCH branch
until [ "$(snapcraft status core | grep $BETA_RELEASE_BRANCH | awk '{print $2}' | sort | uniq)" = "$NEW_VERSION" ]; do
sleep 60
echo "waiting for core snap to be published to beta release branch"
done
snapcraft promote core --from-channel="$BETA_RELEASE_BRANCH" --to-channel=beta
# create a new branch merging the changelog from the release/ branch back to
# master
git checkout master
git checkout -b release-${NEW_VERSION}-changelog
git merge ${RELEASE_BRANCH}
# TODO: double check that the right files are changed
git push release-${NEW_VERSION}-changelog $PERSONAL_FORK
# TODO: create a new PR to master with the release branch changelog changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment