瀏覽代碼

Build .deb packages for some architectures on CI to publish on GitHub

timvisee 7 年之前
父節點
當前提交
faccbf6b32
共有 8 個文件被更改,包括 75 次插入5 次删除
  1. 9 4
      .travis.yml
  2. 1 1
      Cargo.toml
  3. 37 0
      pkg/create_deb
  4. 11 0
      pkg/deb/DEBIAN/control
  5. 7 0
      pkg/deb/DEBIAN/postinst
  6. 9 0
      pkg/deb/DEBIAN/prerm
  7. 1 0
      pkg/deb/blah.txt
  8. 二進制
      pkg/deb/usr/bin/ffsend

+ 9 - 4
.travis.yml

@@ -73,7 +73,7 @@ jobs:
     # GitHub binary release for Linux on x86/x86_64
     - stage: release
       rust: stable
-      env: TARGET=x86_64-unknown-linux-gnu TARGET_SIMPLE=linux-x64
+      env: TARGET=x86_64-unknown-linux-gnu TARGET_SIMPLE=linux-x64 DEB_ARCH=amd64
       cache: cargo
       script: &script-github-release
         - |
@@ -87,13 +87,19 @@ jobs:
             cp target/$TARGET/release/ffsend ./ffsend
           fi
         - tar -czvf ./ffsend-$TARGET_SIMPLE-$TRAVIS_TAG.tar.gz ./ffsend
+        - |
+          if [ -n "$DEB_ARCH" ]; then
+            ./pkg/create_deb
+          fi
         - mv ./ffsend ./ffsend-$TARGET_SIMPLE-$TRAVIS_TAG
       deploy: &deploy-github-release
         provider: releases
         api_key: $GITHUB_OAUTH_TOKEN
         skip_cleanup: true
         overwrite: true
+        file_glob: true
         file:
+          - ffsend_*.deb
           - ffsend-$TARGET_SIMPLE-$TRAVIS_TAG.tar.gz
           - ffsend-$TARGET_SIMPLE-$TRAVIS_TAG
         on:
@@ -101,7 +107,7 @@ jobs:
           branch: master
     - stage: release
       rust: stable
-      env: TARGET=i686-unknown-linux-gnu TARGET_SIMPLE=linux-i686
+      env: TARGET=i686-unknown-linux-gnu TARGET_SIMPLE=linux-i686 DEB_ARCH=i386
       cache: cargo
       install: &install-github-release-cross
         - cargo install cross
@@ -140,8 +146,7 @@ jobs:
       script: *script-github-release
       deploy: *deploy-github-release
 
+# TODO: add Windows architecture (using AppVeyor)
 # TODO: add (Free)BSD architecture
-# TODO: use regular cargo commands for x86_64 linux
-# TODO: release a build for each architecture
 # TODO: enfore the git tag/crate version equality for releases
 # TODO: disable addons/rust installation for GitHub release job

+ 1 - 1
Cargo.toml

@@ -1,7 +1,7 @@
 [package]
 name = "ffsend"
 version = "0.0.3"
-authors = ["Tim Visee <https://timvisee.com/>"]
+authors = ["Tim Visee <timvisee@gmail.com>"]
 license = "GPL-3.0"
 readme = "README.md"
 homepage = "https://github.com/timvisee/ffsend"

+ 37 - 0
pkg/create_deb

@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -e
+
+# Ensure the version tag is valid
+if [[ ! $TRAVIS_TAG =~ ^v([0-9]+\.)*[0-9]+$ ]]; then
+    echo "Error: invalid Git tag in \$TRAVIS_TAG, must be in 'v0.0.0' format"
+    exit 1
+fi
+
+# Ensure the debian architecture is set
+if [[ -z "$DEB_ARCH" ]]; then
+    echo "Error: debian architecture not configured in \$DEB_ARCH"
+    exit 1
+fi
+
+# Define some useful variables
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+VERSION=${TRAVIS_TAG:1}
+
+# Ensure the binary file exists
+if [[ ! -f "$DIR/../ffsend" ]]; then
+    echo "Error: missing 'ffsend' binary in repository root"
+    exit 1
+fi
+
+# Copy the binary into the package directory
+mkdir -p $DIR/deb/usr/bin
+cp $DIR/../ffsend $DIR/deb/usr/bin/ffsend
+
+# Update version and architecture in the control file
+sed -i "/Version:\.*/c\\Version: $VERSION" $DIR/deb/DEBIAN/control
+sed -i "/Architecture:\.*/c\\Architecture: $DEB_ARCH" $DIR/deb/DEBIAN/control
+
+# Build the debian package
+echo "Building debian package..."
+dpkg-deb --verbose --build $DIR/deb .

+ 11 - 0
pkg/deb/DEBIAN/control

@@ -0,0 +1,11 @@
+Package: ffsend
+Version: TODO
+Section: utils
+Priority: standard
+Architecture: TODO
+Recommends: xclip
+Maintainer: Tim Visée <timvisee@gmail.com>
+Description: easily and securely share files from the CLI using Send
+ Easily and securely share files from the command line.
+ A fully featured Firefox Send client.
+Homepage: https://github.com/timvisee/ffsend

+ 7 - 0
pkg/deb/DEBIAN/postinst

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+# Create an ffs alias
+if [[ ! -f /usr/bin/ffs ]]; then
+    echo "Creating ffs alias for ffsend..."
+    ln -s /usr/bin/ffsend /usr/bin/ffs
+fi

+ 9 - 0
pkg/deb/DEBIAN/prerm

@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+# Unlink the ffs alias if it links to ffsend
+if [[ -L /usr/bin/ffs ]] \
+    && [[ $(ls -l /usr/bin/ffs | sed -e 's/.* -> //') == "/usr/bin/ffsend" ]]; \
+then
+    echo "Removing ffs alias for ffsend..."
+    unlink /usr/bin/ffs
+fi

+ 1 - 0
pkg/deb/blah.txt

@@ -0,0 +1 @@
+Some file contents

二進制
pkg/deb/usr/bin/ffsend