Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple OS and ARCH for signing #1674

Merged
merged 3 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions package-upload.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
tasks:
- task: s3.BucketCopy
name: upload
name: amd64
src: $HOME/projects/go-algorand/tmp/node_pkgs/linux/amd64
dest: s3://$STAGING/$CHANNEL/$VERSION
dest: s3://$STAGING/$CHANNEL/$VERSION/

- task: s3.BucketCopy
name: arm
src: $HOME/projects/go-algorand/tmp/node_pkgs/linux/arm
dest: s3://$STAGING/$CHANNEL/$VERSION/

- task: s3.BucketCopy
name: arm64
src: $HOME/projects/go-algorand/tmp/node_pkgs/linux/arm64
dest: s3://$STAGING/$CHANNEL/$VERSION/

jobs:
package-upload:
tasks:
- s3.BucketCopy.upload
- s3.BucketCopy.amd64
- s3.BucketCopy.arm
- s3.BucketCopy.arm64

84 changes: 47 additions & 37 deletions scripts/release/mule/sign/sign.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#!/usr/bin/env bash
# shellcheck disable=2035,2129
# shellcheck disable=2035,2129,2162

# TODO: This needs to be reworked a bit to support Darwin.

set -exo pipefail

echo
date "+build_release begin SIGN stage %Y%m%d_%H%M%S"
echo

ARCH_BIT=$(uname -m)
ARCH_TYPE=$(./scripts/archtype.sh)
OS_TYPE=$(./scripts/ostype.sh)
VERSION=${VERSION:-$(./scripts/compute_build_number.sh -f)}
BRANCH=${BRANCH:-$(./scripts/compute_branch.sh)}
CHANNEL=${CHANNEL:-$(./scripts/compute_branch_channel.sh "$BRANCH")}
PKG_DIR="./tmp/node_pkgs/$OS_TYPE/$ARCH_TYPE"
PKG_DIR="./tmp/node_pkgs"
[email protected]
STATUSFILE="build_status_${CHANNEL}_${VERSION}"

Expand All @@ -25,48 +24,59 @@ STATUSFILE="build_status_${CHANNEL}_${VERSION}"
find /root/.gnupg -type d -exec chmod 700 {} \;
find /root/.gnupg -type f -exec chmod 600 {} \;

mkdir -p "$PKG_DIR"
cd "$PKG_DIR"

if [ -n "$S3_SOURCE" ]
then
PREFIX="$S3_SOURCE/$CHANNEL/$VERSION"

# deb
aws s3 cp "s3://$PREFIX/algorand_${CHANNEL}_${OS_TYPE}-${ARCH_TYPE}_${VERSION}.deb" .
aws s3 cp "s3://$PREFIX/algorand-devtools_${CHANNEL}_${OS_TYPE}-${ARCH_TYPE}_${VERSION}.deb" .

# rpm
aws s3 cp "s3://$PREFIX/algorand-${VERSION}-1.${ARCH_BIT}.rpm" .
aws s3 cp "s3://$PREFIX/algorand-devtools-${VERSION}-1.${ARCH_BIT}.rpm" .
aws s3 cp --recursive --exclude "*" --include "*$CHANNEL*$VERSION*" "s3://$S3_SOURCE/$CHANNEL/$VERSION" .
fi

# TODO: "$PKG_TYPE" == "source"

# Clean package directory of any previous operations.
rm -rf hashes* *.sig *.asc *.asc.gz

for file in *.tar.gz *.deb
do
gpg -u "$SIGNING_KEY_ADDR" --detach-sign "$file"
done

for file in *.rpm
do
gpg -u [email protected] --detach-sign "$file"
# https://unix.stackexchange.com/a/46259
# Grab the directories directly underneath (max-depth 1) ./tmp/node_pkgs/ into a space-delimited string.
# This will help us target `linux`, `darwin` and (possibly) `windows` build assets.
# Note the surrounding parens turns the string created by `find` into an array.
OS_TYPES=($(find . -mindepth 1 -maxdepth 1 -type d -printf '%f\n'))
for os in "${OS_TYPES[@]}"; do
if [ "$os" = linux ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to also sign the darwin builds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's my understanding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, but we aren't building them yet. Because of the ARCHS loop below, it'd probably need to be a separate block anyway.

then
ARCHS=(amd64 arm arm64)
for arch in "${ARCHS[@]}"; do
(
mkdir -p "$os/$arch"
cd "$os/$arch"

# Clean package directory of any previous operations.
rm -rf hashes* *.sig *.asc *.asc.gz

for file in *.tar.gz *.deb
do
gpg -u "$SIGNING_KEY_ADDR" --detach-sign "$file"
done

for file in *.rpm
do
gpg -u [email protected] --detach-sign "$file"
done

HASHFILE="hashes_${CHANNEL}_${os}_${arch}_${VERSION}"

md5sum *.tar.gz *.deb *.rpm >> "$HASHFILE"
shasum -a 256 *.tar.gz *.deb *.rpm >> "$HASHFILE"
shasum -a 512 *.tar.gz *.deb *.rpm >> "$HASHFILE"

gpg -u "$SIGNING_KEY_ADDR" --detach-sign "$HASHFILE"
gpg -u "$SIGNING_KEY_ADDR" --clearsign "$HASHFILE"

gpg -u "$SIGNING_KEY_ADDR" --clearsign "$STATUSFILE"
gzip -c "$STATUSFILE.asc" > "$STATUSFILE.asc.gz"
)
done
fi
done

HASHFILE="hashes_${CHANNEL}_${OS_TYPE}_${ARCH_TYPE}_${VERSION}"

md5sum *.tar.gz *.deb *.rpm >> "$HASHFILE"
shasum -a 256 *.tar.gz *.deb *.rpm >> "$HASHFILE"
shasum -a 512 *.tar.gz *.deb *.rpm >> "$HASHFILE"

gpg -u "$SIGNING_KEY_ADDR" --detach-sign "$HASHFILE"
gpg -u "$SIGNING_KEY_ADDR" --clearsign "$HASHFILE"

gpg -u "$SIGNING_KEY_ADDR" --clearsign "$STATUSFILE"
gzip -c "$STATUSFILE.asc" > "$STATUSFILE.asc.gz"

echo
date "+build_release end SIGN stage %Y%m%d_%H%M%S"
echo
Expand Down