From d798d13968572b09e18237f3e16e225815dabc40 Mon Sep 17 00:00:00 2001 From: Rudra-IITM <120119520+Rudra-IITM@users.noreply.github.com> Date: Fri, 9 Feb 2024 19:32:14 +0000 Subject: [PATCH] Use the Snap versioning automation of ubuntu/desktop-snaps (#20) Remove the versioning automation scripting from snapcraft.yaml and add the needed changes so that the GitHub action of ubuntu/desktop-snaps does the versioning automation. - Hard-code "version" and "grade" metadata fields in snapcraft.yaml. The GitHub action modifies this file to bump the version. This also improves readability, having the current version number visible near the top of the file. - Remove the versioning automation scripting in the "override-pull:" in the "cups" part. We use the versioning automation in the GitHub action and do not need our own script any more. - Remove the "jq" from the "build-packages:" in the "cups" part. This was only needed for our own versioning automation script. - In the workflow file, .github/workflows/auto-update.yml, we add the parameter "version-schema: 'v(\d+\.\d+\.\d+)'" to the call of the GitHub action. This tells to the action to also perform versioning automation and it also tells the format of the upstream release tags and the upstream version number in them. - We do not remove the "adopt-info: cups" even with all metadata fields in snapcraft.yaml being hard-coded and no "craftctl set ..." calls in the "cuos" part. It only tells the GitHub action which part is the supplier of the upstream version number. --- .github/workflows/auto-update.yml | 1 + snapcraft.yaml | 59 ++----------------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index 84c7b32..3754988 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -17,3 +17,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} repo: ${{ github.repository }} + version-schema: 'v(\d+\.\d+\.\d+)' diff --git a/snapcraft.yaml b/snapcraft.yaml index 08ba1f7..e07932d 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,5 +1,7 @@ name: cups base: core22 # The base Snap is the execution environment for this Snap +version: '2.4.7-6' +grade: stable summary: CUPS-based printing stack Snap description: Complete printing environment in a Snap confinement: strict @@ -196,62 +198,6 @@ parts: # Do the actual pull task craftctl default # Settings: - # Force channel: auto/devel/edge/stable - CHANNEL=stable - # Force package release number (integer) or "auto" - PACKAGERELEASE=auto - # Time stamp of Snap build in Snap Store - snapbuilddatehuman=`curl -s -H 'Snap-Device-Series: 16' https://api.snapcraft.io/v2/snaps/info/cups | jq -r '."channel-map" | .[] | select(.channel.name == "edge") | select(.channel.architecture == "amd64") | ."created-at"'` - snapbuilddate=`date +%s --date=$snapbuilddatehuman` - if [ -z "$snapbuilddate" ]; then - snapbuilddate=0 - fi - # Time stamp of the last GIT commit of the snapping repository - pushd $CRAFT_PROJECT_DIR - gitcommitdate=`git log -1 --date=unix | grep Date: | perl -p -e 's/Date:\s*//'` - popd - if [ -z "$gitcommitdate" ]; then - gitcommitdate=0 - fi - # Previous stable and development version - prevstable="$(curl -s -H 'Snap-Device-Series: 16' https://api.snapcraft.io/v2/snaps/info/cups | jq -r '."channel-map" | .[] | select(.channel.name == "stable") | select(.channel.architecture == "'$CRAFT_TARGET_ARCH'") | .version')" - if [ -z "$prevstable" ]; then - prevstable=0 - fi - prevdevel="$(curl -s -H 'Snap-Device-Series: 16' https://api.snapcraft.io/v2/snaps/info/cups | jq -r '."channel-map" | .[] | select(.channel.name == "edge") | select(.channel.architecture == "'$CRAFT_TARGET_ARCH'") | .version')" - if [ -z "$prevdevel" ]; then - prevdevel=0 - fi - # Previous version in general - dpkg --compare-versions "$prevdevel" lt "$prevstable" && prevversion=$prevstable || prevversion=$prevdevel - # Current upstream version of CUPS - upstreamversion="$(git describe --tags --always | sed -e 's/^v//;s/-/+git/;y/-/./')" - # Determine package release number - if test "x$PACKAGERELEASE" = "xauto"; then - packagerelease=`echo "$prevversion" | perl -p -e 's/^('"$upstreamversion"'\-(\d+)|.*)$/\2/'` - if [ -z "$packagerelease" ]; then - packagerelease=1 - else - if test "$gitcommitdate" -gt "$snapbuilddate"; then - packagerelease=$(( $packagerelease + 1 )) - fi - fi - else - packagerelease=$PACKAGERELEASE - fi - # Compose version string - version="$upstreamversion-$packagerelease" - # Select channel - if test "x$CHANNEL" = "xedge" -o "x$CHANNEL" = "xdevel"; then - grade=devel - elif test "x$CHANNEL" = "xstable"; then - grade=stable - else - [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable - fi - # Set version and grade - craftctl set version="$version" - craftctl set grade="$grade" # Patch to use snapctl with the slot name "cups-server" for Snap mediation #patch -p1 < $CRAFT_PROJECT_DIR/patches/use-snapctl-with-slot-cups-server.patch # Longer timeout for Avahi resolving for cupsGetDests() API function, used @@ -261,7 +207,6 @@ parts: - git - sed - curl - - jq - perl-base - patch - autoconf