Skip to content

Commit

Permalink
Switch to single-binary releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtuchkin committed Nov 25, 2019
1 parent 98789d5 commit 6cfe9ad
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ deploy:
- provider: releases
api_key:
secure: "ZnbuFXVEqc+VbcYYjyCLsRxBL2P6jUJSBqQ7S19fZfa7Od8pIxz/gJ9bQPWMVqeYtsgP/PD3VaqsUiMGIn+J174yMonQI3fR/XR6UpbGSs7YaFg2Fa7yfGt5NDgMhi0eZt+EqWA0yoin0JKO0BPMpsN2ik45zdy4rw/ATa+XES3PDS455nCR1K6pD/7FOP7h+H3hmVKFx+8fY6Ojy8lhYRDpnt9/91wb0pDlg5nnEJHVH1/TSvmiTUXFcq9SPehcKCkiQyC0+drY44Ex58/QG9uRf6vOxIsirJKqgnfAe8zjBCz2vZbO04DcygfJYku4tQj+MD2h12kDrQppn6TkRk768U5ktF31I30OU7/PW83dJ1hrE64MICB+yHf+w9gEzmKV4vdAAXaghjdTojIWd1dzNGmWY8K8RDhyJsuO9NO7NkGqA9vfAYODk0Oz9U0wTVBdcd1n/zSf5EjSM4Gg9YgIliTfcQiA3j8L332DZi7J6dC46RJHuZjQfemDrnBkF4vcAXYEVouzIhQHzVX/VE+CgIe/ayXMSOYcUju/1rhb2ktKoqV49pOaEZ3SGA76pkhHAGy4gnm2sadQDSp0SocQ4PTY4vLim7nXrQiuLMb722waz7KaBCSw1/MegDmXQ9sF1iZP2g1b7kUVwES+3Xjg/oer7jU2pDHLJyP8IHQ="
file: deployment/*
file: deployment/**/*
file_glob: true
skip_cleanup: true
on:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Supports advanced use cases like multiple passwords/public keys, [key threshold schemes](https://en.wikipedia.org/wiki/Secret_sharing) and more.
* Fast. ~1.1 Gb/s on a 2013 MacBook using AES256-GCM algorithm. Usually I/O bandwidth is the limiting factor.
* Easy to use at both beginner and advanced level (see examples below).
* Lightweight: ~1 Mb binary size; <10 Mb memory used (except as required by password derivation functions).
* Lightweight, single-binary distribution: ~1 Mb binary size; <10 Mb memory used (except as required by password derivation functions).
* Operating System Support: x86 Linux, MacOS, Windows.
* Open source, MIT license.

Expand Down
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ before_deploy:
- cargo rustc --target %TARGET% --release --bins -- -C lto
- ps: ci\before_deploy.ps1

artifacts:
- path: deployment\**\*.*

deploy:
- artifact: /.*\.zip/
- artifact: /.*/
auth_token:
secure: qWDXszRXbGzhtHi9+Z4fRzRWpSW+XsK6IWXXPgTmgfSPSNRvEvPv+hHG57btbqMc
description: ''
Expand Down
29 changes: 12 additions & 17 deletions ci/before_deploy.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
# This script takes care of packaging the build artifacts that will go in the
# release zipfile

$SRC_DIR = $PWD.Path
New-Item -Type Directory -Name deployment
# Create target folder to put files in.
$TARGET_DIR = ".\deployment\$($Env:FRIENDLY_TARGET_NAME)"
New-Item -Type Directory -Path $TARGET_DIR

Set-Location $ENV:Temp
$STAGE = [System.Guid]::NewGuid().ToString()
New-Item -Type Directory -Name $STAGE
Set-Location $STAGE
# Copy the binary file. This is the only actual file we're packaging.
Copy-Item ".\target\$($Env:TARGET)\release\$($Env:PROJECT_NAME).exe" "$TARGET_DIR\"

$ZIP = "$SRC_DIR\deployment\$($Env:PROJECT_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:FRIENDLY_TARGET_NAME).zip"
Push-Location "$TARGET_DIR"

# TODO Update this to package the right artifacts
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\$($Env:PROJECT_NAME).exe" '.\'
Copy-Item "$SRC_DIR\README.md" '.\'
Copy-Item "$SRC_DIR\LICENSE" '.\'
# Create a basic SHASUM file
(Get-ChildItem -File "." |
Get-FileHash -Algorithm SHA256 |
Format-Table -Property @{Name='Path';Expression={Resolve-Path -Relative $_.Path}},Hash -AutoSize -HideTableHeaders |
Out-String).Trim() | Out-File -Path "./SHA256SUM"

7z a "$ZIP" *

Push-AppveyorArtifact "$ZIP"

Remove-Item *.* -Force
Set-Location $SRC_DIR
Pop-Location
74 changes: 26 additions & 48 deletions ci/before_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,30 @@
# This requires skip_cleanup: true option.
# Also current working directory for this whole script is the main repo directory.

fill_tarball_contents() {
local STAGING_DIR="$1"

# Copy main binary to the staging directory and make it smaller
cp "target/$TARGET/release/$PROJECT_NAME" "$STAGING_DIR/"
local RYPT_BINARY="$STAGING_DIR/$PROJECT_NAME"
strip "$RYPT_BINARY"

# Sanity check that git tag corresponds to binary version
local VERSION=$("$RYPT_BINARY" --version | head -n 1)
if [[ "$VERSION" != "$PROJECT_NAME ${TRAVIS_TAG#v}" ]]; then
echo "Binary version \"$VERSION\" does not correspond to tag \"$TRAVIS_TAG\""
exit 1
fi

# Copy readme and license
cp {README.md,LICENSE} "$STAGING_DIR/"

# Print contents of the archive
ls -l "$STAGING_DIR/"
}

create_tarball() {
local DEPLOYMENT_DIR="$1"
local NAME="$2"

# Ensure we're not reusing deployment directory
rm -rf "$DEPLOYMENT_DIR"

# Create a staging directory to keep the future tarball contents
local STAGING_DIR="$DEPLOYMENT_DIR/$NAME"
mkdir -p "$STAGING_DIR"

fill_tarball_contents "$STAGING_DIR"

# Create the tarball in the deployment directory
(cd "$DEPLOYMENT_DIR" && tar czf "$NAME.tar.gz" "$NAME")
ls -l "$DEPLOYMENT_DIR/$NAME.tar.gz"

rm -rf "$STAGING_DIR"
}

# Name of the tarball and the folder inside the tarball
NAME="$PROJECT_NAME-$TRAVIS_TAG-$FRIENDLY_TARGET_NAME"

# Main folder to be used in deployment. This whole directory will be uploaded to GitHub releases.
# Deployment base folder relative to main repo directory. All contents of this directory will be uploaded to GitHub releases.
DEPLOYMENT_DIR="deployment"

create_tarball "$DEPLOYMENT_DIR" "$NAME"
rm -rf "$DEPLOYMENT_DIR"
mkdir "$DEPLOYMENT_DIR"

# Create a per-target directory where we'll put the actual files
TARGET_DIR="$DEPLOYMENT_DIR/$FRIENDLY_TARGET_NAME"
mkdir "$TARGET_DIR"

# Copy main binary to the staging directory and make it smaller
cp "target/$TARGET/release/$PROJECT_NAME" "$TARGET_DIR/"
RYPT_BINARY="$TARGET_DIR/$PROJECT_NAME"
strip "$RYPT_BINARY"

# Sanity check that git tag corresponds to binary version
VERSION=$("$RYPT_BINARY" --version | head -n 1)
if [[ "$VERSION" != "$PROJECT_NAME ${TRAVIS_TAG#v}" ]]; then
echo "Error: Binary version \"$VERSION\" does not correspond to tag \"$TRAVIS_TAG\""
exit 1
fi

# Calculate SHA256 hash of the file(s) in the staging directory.
(cd "$TARGET_DIR" && sha256sum -b -- * > SHA256SUMS)

# Print contents of the archive and the sha sums
ls -l "$TARGET_DIR/"
cat "$TARGET_DIR/SHA256SUMS"

0 comments on commit 6cfe9ad

Please sign in to comment.