Просмотр исходного кода

Merge branch 'aur-fix' into 'master'

Fix AUR package names, add git master package, improve automatic releases

Closes #64

See merge request timvisee/ffsend!25
Tim Visée 6 лет назад
Родитель
Сommit
29a54d7724
5 измененных файлов с 128 добавлено и 41 удалено
  1. 66 17
      .gitlab-ci.yml
  2. 0 18
      pkg/aur/bin/PKGBUILD
  3. 24 0
      pkg/aur/ffsend-bin/PKGBUILD
  4. 29 0
      pkg/aur/ffsend-git/PKGBUILD
  5. 9 6
      pkg/aur/ffsend/PKGBUILD

+ 66 - 17
.gitlab-ci.yml

@@ -263,31 +263,65 @@ package-aur:
   script:
     - cd ./pkg/aur
 
-    # Update version number in PKGBUILD
+    # Determine the version number we're releasing for
     - VERSION=$(echo $CI_COMMIT_REF_NAME | cut -c 2-)
-    - echo "Determined binary version number 'v$VERSION', updating PKGBUILDs..."
-    - sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i bin/PKGBUILD
-    - sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i git/PKGBUILD
+    - echo "Determined binary version number 'v$VERSION'"
+
+    # Determine remote URLs and SHA checksums
+    - echo "Determining SHA checksums for remote files..."
+    - URL_BIN=https://github.com/timvisee/ffsend/releases/download/v$VERSION/ffsend-v$VERSION-linux-x64-static
+    - URL_SOURCE=https://gitlab.com/timvisee/ffsend/-/archive/v$VERSION/ffsend-v$VERSION.tar.gz
+    - 'echo "Selected binary URL: $URL_BIN"'
+    - 'echo "Selected source URL: $URL_SOURCE"'
+    - echo "Determining sha256sum for remote binary..."
+    - 'SHA_BIN=$(curl -sSL "$URL_BIN" | sha256sum | cut -d" " -f1)'
+    - 'echo "Got sha256sum: $SHA_BIN"'
+    - echo "Determining sha256sum for remote source..."
+    - 'SHA_SOURCE=$(curl -sSL "$URL_SOURCE" | sha256sum | cut -d" " -f1)'
+    - 'echo "Got sha256sum: $SHA_SOURCE"'
+
+    # Update PKGBUILD parameters: version, source URL and SHA sum
+    - echo "Updating PKGBUILDS with release information..."
+    - sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i ffsend/PKGBUILD
+    - sed "s/^pkgver=.*\$/pkgver=$VERSION/" -i ffsend-bin/PKGBUILD
+    - sed "s/^pkgver=.*\$/pkgver=$VERSION.$CI_COMMIT_SHORT_SHA/" -i ffsend-git/PKGBUILD
+    - sed "s/^source=(\"\(.*\)::.*\").*\$/source=('\1::$(echo $URL_SOURCE | sed 's/\//\\\//g')')/" -i ffsend/PKGBUILD
+    - sed "s/^source=(\"\(.*\)::.*\").*\$/source=('\1::$(echo $URL_BIN | sed 's/\//\\\//g')')/" -i ffsend-bin/PKGBUILD
+    - sed "s/^sha256sums=.*\$/sha256sums=('$SHA_SOURCE')/" -i ffsend/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
     - echo "Installing required build packages..."
     - pacman -Syu --noconfirm sudo base-devel binutils openssh rust cargo cmake git openssl
 
     # Make AUR package
-    - echo "Making AUR package..."
     - mkdir -p /.cargo
     - chmod -R 777 /.cargo
-    - cd bin/
+    - cd ffsend-bin/
     - echo "Making binary package..."
     - sudo -u nobody makepkg -c
     - sudo -u nobody makepkg --printsrcinfo > .SRCINFO
-    - cd ../git
-    - echo "Making git source package..."
+    - cd ../ffsend
+    - echo "Making main 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 ..
 
-      # Set up SSH for publishing
+    # Set up SSH for publishing
     - mkdir -p /root/.ssh
     - cp ./aur.pub /root/.ssh/id_rsa.pub
     - echo "$AUR_SSH_PRIVATE" > /root/.ssh/id_rsa
@@ -301,22 +335,37 @@ package-aur:
     - git config --global user.name "timvisee"
     - git config --global user.email "tim@visee.me"
 
-      # Publish binary package: clone AUR repo, commit update and push
-    - git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend-bin
-    - cd aur-ffsend-bin
-    - cp ../bin/{PKGBUILD,.SRCINFO} ./
+    # Publish main package: clone AUR repo, commit update and push
+    - git clone ssh://aur@aur.archlinux.org/ffsend.git aur-ffsend
+    - cd aur-ffsend
+    - cp ../ffsend/{PKGBUILD,.SRCINFO} ./
     - git add PKGBUILD .SRCINFO
     - git commit -m "Release v$VERSION"
     - git push
     - cd ..
 
-      # Publish git package: clone AUR repo, commit update and push
-    - git clone ssh://aur@aur.archlinux.org/ffsend-git.git aur-ffsend-git
-    - cd aur-ffsend-git
-    - cp ../git/{PKGBUILD,.SRCINFO} ./
+    # Publish binary package: clone AUR repo, commit update and push
+    - git clone ssh://aur@aur.archlinux.org/ffsend-bin.git aur-ffsend-bin
+    - cd aur-ffsend-bin
+    - cp ../ffsend-bin/{PKGBUILD,.SRCINFO} ./
     - git add PKGBUILD .SRCINFO
     - git commit -m "Release v$VERSION"
     - git push
     - cd ..
 
+    # Publish git package: clone AUR repo, commit update and push
+    # 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

+ 0 - 18
pkg/aur/bin/PKGBUILD

@@ -1,18 +0,0 @@
-# Maintainer: Tim Visee <tim@visee.me>
-
-pkgname=ffsend
-pkgver=0.0.0
-pkgrel=1
-pkgdesc="Easily and securely share files from the command line. A Firefox Send client."
-url="https://gitlab.com/timvisee/ffsend"
-license=('GPL3')
-conflicts=('ffsend-git')
-source=("ffsend::https://github.com/timvisee/ffsend/releases/download/v$pkgver/ffsend-v$pkgver-linux-x64-static")
-sha256sums=('SKIP')
-arch=('x86_64')
-depends=('ca-certificates')
-optdepends=('xclip: clipboard support')
-
-package() {
-    install -D "$srcdir/ffsend" "$pkgdir/usr/bin/ffsend"
-}

+ 24 - 0
pkg/aur/ffsend-bin/PKGBUILD

@@ -0,0 +1,24 @@
+# Maintainer: Tim Visee <tim@visee.me>
+# Contributor: Ariel AxionL <i at axionl dot me>
+#
+# This PKGBUILD is managed externally, and is automatically updated here:
+# - https://gitlab.com/timvisee/ffsend/blob/master/pkg/aur/ffsend-bin/PKGBUILD
+# - Mirror: https://github.com/timvisee/ffsend/blob/master/pkg/aur/ffsend-bin/PKGBUILD
+
+pkgname=ffsend-bin
+pkgver=0.0.0 # automatically set in CI, see: /.gitlab-ci.yml
+pkgrel=1
+pkgdesc="Easily and securely share files from the command line. A Firefox Send client."
+url="https://gitlab.com/timvisee/ffsend"
+license=('GPL3')
+source=("ffsend::https://github.com/timvisee/ffsend/releases/download/v$pkgver/ffsend-v$pkgver-linux-x64-static") # automatically set in CI, see: /.gitlab-ci.yml
+sha256sums=('SKIP') # automatically set in CI, see: /.gitlab-ci.yml
+arch=('x86_64')
+provides=('ffsend')
+conflicts=('ffsend')
+depends=('ca-certificates')
+optdepends=('xclip: clipboard support')
+
+package() {
+    install -D "$srcdir/ffsend" "$pkgdir/usr/bin/ffsend"
+}

+ 29 - 0
pkg/aur/ffsend-git/PKGBUILD

@@ -0,0 +1,29 @@
+# Maintainer: Tim Visee <tim@visee.me>
+#
+# This PKGBUILD is managed externally, and is automatically updated here:
+# - https://gitlab.com/timvisee/ffsend/blob/master/pkg/aur/ffsend-git/PKGBUILD
+# - Mirror: https://github.com/timvisee/ffsend/blob/master/pkg/aur/ffsend-git/PKGBUILD
+
+pkgname=ffsend-git
+pkgver=0.0.0 # automatically set in CI, see: /.gitlab-ci.yml
+pkgrel=1
+pkgdesc="Easily and securely share files from the command line. A Firefox Send client."
+url="https://gitlab.com/timvisee/ffsend"
+license=('GPL3')
+source=("ffsend::git+$url.git")
+sha256sums=('SKIP')
+arch=('x86_64' 'i686')
+provides=('ffsend')
+conflicts=('ffsend')
+depends=('ca-certificates')
+makedepends=('openssl>=1.0' 'rust>=1.32' 'cargo' 'cmake')
+optdepends=('xclip: clipboard support')
+
+build() {
+    cd ffsend
+    env CARGO_INCREMENTAL=0 cargo build --release
+}
+
+package() {
+    install -Dm755 "$srcdir/ffsend/target/release/ffsend" "$pkgdir/usr/bin/ffsend"
+}

+ 9 - 6
pkg/aur/git/PKGBUILD → pkg/aur/ffsend/PKGBUILD

@@ -1,16 +1,19 @@
 # Maintainer: Tim Visee <tim@visee.me>
+#
+# This PKGBUILD is managed externally, and is automatically updated here:
+# - https://gitlab.com/timvisee/ffsend/blob/master/pkg/aur/ffsend/PKGBUILD
+# - Mirror: https://github.com/timvisee/ffsend/blob/master/pkg/aur/ffsend/PKGBUILD
 
-pkgname=ffsend-git
-pkgver=0.0.0
+pkgname=ffsend
+pkgver=0.0.0 # automatically set in CI, see: /.gitlab-ci.yml
 pkgrel=1
 pkgdesc="Easily and securely share files from the command line. A Firefox Send client."
 url="https://gitlab.com/timvisee/ffsend"
 license=('GPL3')
-provides=('ffsend')
-conflicts=('ffsend')
-source=("ffsend-v$pkgver.tar.gz::$url/-/archive/v$pkgver/ffsend-v$pkgver.tar.gz")
-sha256sums=('SKIP')
+source=("ffsend-v$pkgver.tar.gz::$url/-/archive/v$pkgver/ffsend-v$pkgver.tar.gz") # automatically set in CI, see: /.gitlab-ci.yml
+sha256sums=('SKIP') # automatically set in CI, see: /.gitlab-ci.yml
 arch=('x86_64' 'i686')
+provides=('ffsend')
 depends=('ca-certificates')
 makedepends=('openssl>=1.0' 'rust>=1.32' 'cargo' 'cmake')
 optdepends=('xclip: clipboard support')