]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
snap: Use "snapcraftctl set-grade"
authorAnthony Fok <foka@debian.org>
Tue, 30 Aug 2022 09:52:16 +0000 (03:52 -0600)
committerAnthony Fok <anthony.fok@canada.ca>
Tue, 30 Aug 2022 11:23:18 +0000 (05:23 -0600)
This, together with 'snapcraftctl set-version", negates the need to
modify snap/snapcraft.yaml upon each release, so the corresponding code
is removed from releaser/releaser.go.

Also, vendorInfo is extended to include the snap version number.

See #10225

releaser/releaser.go
snap/snapcraft.yaml

index afb5079a124678ea1a02c20717b0c67ee59d4788..3d00e3a22881ea30e6f9e054a4bf2da75ffca3a6 100644 (file)
@@ -147,16 +147,6 @@ func (r *ReleaseHandler) bumpVersions(ver hugo.Version) error {
                return err
        }
 
-       snapcraftGrade := "stable"
-       if ver.Suffix != "" {
-               snapcraftGrade = "devel"
-       }
-       if err := r.replaceInFile("snap/snapcraft.yaml",
-               `version: "(.*)"`, fmt.Sprintf(`version: "%s"`, ver),
-               `grade: (.*) #`, fmt.Sprintf(`grade: %s #`, snapcraftGrade)); err != nil {
-               return err
-       }
-
        var minVersion string
        if ver.Suffix != "" {
                // People use the DEV version in daily use, and we cannot create new themes
index 64083bcc46316f09e60dd95644183fa49c1a2135..c09eb98ae0501ed85502fb4c6612199ab0ca901a 100644 (file)
@@ -10,7 +10,6 @@ description: |
 license: "Apache-2.0"
 base: core20
 confinement: strict
-grade: devel # "devel" or "stable"
 adopt-info: hugo
 
 package-repositories:
@@ -80,6 +79,11 @@ parts:
     override-pull: |
       snapcraftctl pull
       snapcraftctl set-version "$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')"
+      if grep -q 'Suffix:\s*""' common/hugo/version_current.go; then
+        snapcraftctl set-grade "stable"
+      else
+        snapcraftctl set-grade "devel"
+      fi
     override-build: |
       echo "\nStarting override-build:"
       set -ex
@@ -104,7 +108,7 @@ parts:
       fi
 
       echo " * Building hugo (HUGO_BUILD_TAGS=\"$HUGO_BUILD_TAGS\")..."
-      go build -v -ldflags '-X github.com/gohugoio/hugo/common/hugo.vendorInfo=snap' -tags "$HUGO_BUILD_TAGS"
+      go build -v -ldflags "-X github.com/gohugoio/hugo/common/hugo.vendorInfo=snap:$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')" -tags "$HUGO_BUILD_TAGS"
       ./hugo version
       ldd hugo || :