Explorar o código

Only update AUR git package on release if PKGBUILD has changed

timvisee %!s(int64=6) %!d(string=hai) anos
pai
achega
a5f3086dcf
Modificáronse 1 ficheiros con 27 adicións e 13 borrados
  1. 27 13
      .gitlab-ci.yml

+ 27 - 13
.gitlab-ci.yml

@@ -290,6 +290,10 @@ package-aur:
     - sed "s/^sha256sums=.*\$/sha256sums=('$SHA_SOURCE')/" -i ffsend/PKGBUILD
     - sed "s/^sha256sums=.*\$/sha256sums=('$SHA_SOURCE')/" -i ffsend/PKGBUILD
     - sed "s/^sha256sums=.*\$/sha256sums=('$SHA_BIN')/" -i ffsend-bin/PKGBUILD
     - sed "s/^sha256sums=.*\$/sha256sums=('$SHA_BIN')/" -i ffsend-bin/PKGBUILD
 
 
+    # Get SHA hash for local and remote file w/o version, update if it has changed
+    - 'PKGBUILD_STRIP_LOCAL=$(cat ffsend-git/PKGBUILD | sed /^pkgver=.\*/d | sha256sum | cut -d" " -f1)'
+    - 'PKGBUILD_STRIP_REMOTE=$(curl -sSL "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=ffsend-git" | sed /^pkgver=.\*/d | sha256sum | cut -d" " -f1)'
+
     # Install dependencies
     # Install dependencies
     - echo "Installing required build packages..."
     - echo "Installing required build packages..."
     - pacman -Syu --noconfirm sudo base-devel binutils openssh rust cargo cmake git openssl
     - pacman -Syu --noconfirm sudo base-devel binutils openssh rust cargo cmake git openssl
@@ -305,11 +309,16 @@ package-aur:
     - echo "Making main source package..."
     - echo "Making main source package..."
     - sudo -u nobody makepkg -c
     - sudo -u nobody makepkg -c
     - sudo -u nobody makepkg --printsrcinfo > .SRCINFO
     - sudo -u nobody makepkg --printsrcinfo > .SRCINFO
-    # TODO: only do this if the file has changed?
-    - cd ../ffsend-git
-    - echo "Making git source package..."
-    - sudo -u nobody makepkg -c
-    - sudo -u nobody makepkg --printsrcinfo > .SRCINFO
+    # Make git package if different than the remote
+    - |
+      if [ ! "$PKGBUILD_STRIP_LOCAL" == "$PKGBUILD_STRIP_REMOTE" ]; then
+        cd ../ffsend-git
+        echo "Making git source package..."
+        sudo -u nobody makepkg -c
+        sudo -u nobody makepkg --printsrcinfo > .SRCINFO
+      else
+        echo "Not making git source package, it has not changed"
+      fi
     - cd ..
     - cd ..
 
 
     # Set up SSH for publishing
     # Set up SSH for publishing
@@ -345,13 +354,18 @@ package-aur:
     - cd ..
     - cd ..
 
 
     # Publish git package: clone AUR repo, commit update and push
     # Publish git package: clone AUR repo, commit update and push
-    # TODO: only push here if things have changed!
-    - git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend-git
-    - cd aur-ffsend-git
-    - cp ../ffsend-git/{PKGBUILD,.SRCINFO} ./
-    - git add PKGBUILD .SRCINFO
-    - git commit -m "Update PKGBUILD for release v$VERSION"
-    - git push
-    - cd ..
+    # Only publish it if it is different than the remote
+    - |
+      if [ ! "$PKGBUILD_STRIP_LOCAL" == "$PKGBUILD_STRIP_REMOTE" ]; then
+        git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend-git
+        cd aur-ffsend-git
+        cp ../ffsend-git/{PKGBUILD,.SRCINFO} ./
+        git add PKGBUILD .SRCINFO
+        git commit -m "Update PKGBUILD for release v$VERSION"
+        git push
+        cd ..
+      else
+        echo "Not pushing git package, it has not changed"
+      fi
 
 
 # TODO: add job to test ffsend{-git} AUR packages
 # TODO: add job to test ffsend{-git} AUR packages