Skip to content

Commit

Permalink
Improve release process
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeder committed Apr 20, 2023
1 parent 7b27f04 commit 83835db
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 30 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ cd scrypt-kdf
cargo build --release
```

Depending on whether you are using x64 or arm64, you might need to add either the `x86_64-apple-darwin` or the `aarch64-apple-darwin` target accordingly:

```sh
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
```

### Linux x86_x64

In order to get stuff working later, use the `nightly` branch of Rust:
Expand Down Expand Up @@ -90,6 +97,32 @@ CROSS_COMPILE=x86_64-linux-musl- cargo build --target=x86_64-unknown-linux-musl
cargo build --target=x86_64-unknown-linux-musl
```

### For Windows

In order to get stuff working later, use the `nightly` branch of Rust:

```sh
rustup override set nightly
```

Install the standard Windows target on a Mac (note, that the opposite is currently impossible):

```sh
rustup target add x86_64-pc-windows-gnu
```

Use `homebrew` to install mingw-w64:

```sh
brew install mingw-w64
```

Now you can build it:

```sh
cargo build --release --target=x86_64-pc-windows-gnu
```

## Example

Let's try to derive the key for the secret `test`, using the salt `salt`:
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash -e
#!/usr/bin/env sh -e

VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)

Expand All @@ -11,6 +11,9 @@ cargo clippy --all-targets --all-features -- -D warnings
echo "Running tests..."
cargo test --release

echo "Building v${VERSION} for Mac OS arm64..."
cargo build --release --target=aarch64-apple-darwin

echo "Building v${VERSION} for Mac OS..."
cargo build --release --target=x86_64-apple-darwin

Expand All @@ -20,3 +23,6 @@ export CXX_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-g++
export AR_x86_64_unknown_linux_musl=x86_64-unknown-linux-musl-ar
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-unknown-linux-musl-gcc
CROSS_COMPILE=x86_64-linux-musl- cargo build --release --target=x86_64-unknown-linux-musl

echo "Building v${VERSION} for Windows x64..."
cargo build --release --target=x86_64-pc-windows-gnu
104 changes: 75 additions & 29 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,61 +1,107 @@
#!/usr/bin/env bash -e
#!/usr/bin/env sh -e

VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)

./build.sh

rm -rf target/*.tgz target/*.tgz.sig target/release.md

echo "Creating v${VERSION} bundle for Mac OS..."
APPLE_TARGET="scrypt-kdf-${VERSION}-osx.tgz"
APPLE_TARGET_SIG=${APPLE_TARGET}.sig
APPLE_RELEASE="target/${APPLE_TARGET}"
APPLE_RELEASE_SIG=${APPLE_RELEASE}.sig
tar zcvf ${APPLE_RELEASE} target/x86_64-apple-darwin/release/scrypt-kdf
APPLE_RELEASE_SHA512=$(shasum -a512 ${APPLE_RELEASE})
gpg --output ${APPLE_RELEASE_SIG} --detach-sig ${APPLE_RELEASE}
echo "Creating v${VERSION} bundle for Mac OS ARM64..."
APPLE_ARM64_TARGET="scrypt-kdf-${VERSION}-osx-arm64.tgz"
APPLE_ARM64_TARGET_SIG=${APPLE_ARM64_TARGET}.sig
APPLE_ARM64_RELEASE="target/${APPLE_ARM64_TARGET}"
APPLE_ARM64_RELEASE_SIG=${APPLE_ARM64_RELEASE}.sig
tar zcvf ${APPLE_ARM64_RELEASE} target/aarch64-apple-darwin/release/scrypt-kdf
APPLE_ARM64_RELEASE_SHA512=$(shasum -a512 ${APPLE_ARM64_RELEASE})
gpg --output ${APPLE_ARM64_RELEASE_SIG} --detach-sig ${APPLE_ARM64_RELEASE}

echo "Creating v${VERSION} bundle for Mac OS x64..."
APPLE_X64_TARGET="scrypt-kdf-${VERSION}-osx-x64.tgz"
APPLE_X64_TARGET_SIG=${APPLE_X64_TARGET}.sig
APPLE_X64_RELEASE="target/${APPLE_X64_TARGET}"
APPLE_X64_RELEASE_SIG=${APPLE_X64_RELEASE}.sig
tar zcvf ${APPLE_X64_RELEASE} target/x86_64-apple-darwin/release/scrypt-kdf
APPLE_X64_RELEASE_SHA512=$(shasum -a512 ${APPLE_X64_RELEASE})
gpg --output ${APPLE_X64_RELEASE_SIG} --detach-sig ${APPLE_X64_RELEASE}

echo "Creating v${VERSION} bundle for Linux AMD64..."
LINUX_TARGET="scrypt-kdf-${VERSION}-linux-amd64.tgz"
LINUX_TARGET_SIG=${LINUX_TARGET}.sig
LINUX_RELEASE="target/${LINUX_TARGET}"
LINUX_RELEASE_SIG=${LINUX_RELEASE}.sig
tar zcvf ${LINUX_RELEASE} target/x86_64-unknown-linux-musl/release/scrypt-kdf
LINUX_RELEASE_SHA512=$(shasum -a512 ${LINUX_RELEASE})
gpg --output ${LINUX_RELEASE_SIG} --detach-sig ${LINUX_RELEASE}
LINUX_AMD64_TARGET="scrypt-kdf-${VERSION}-linux-amd64.tgz"
LINUX_AMD64_TARGET_SIG=${LINUX_AMD64_TARGET}.sig
LINUX_AMD64_RELEASE="target/${LINUX_AMD64_TARGET}"
LINUX_AMD64_RELEASE_SIG=${LINUX_AMD64_RELEASE}.sig
tar zcvf ${LINUX_AMD64_RELEASE} target/x86_64-unknown-linux-musl/release/scrypt-kdf
LINUX_AMD64_RELEASE_SHA512=$(shasum -a512 ${LINUX_AMD64_RELEASE})
gpg --output ${LINUX_AMD64_RELEASE_SIG} --detach-sig ${LINUX_AMD64_RELEASE}

echo "Creating v${VERSION} bundle for Windows x64..."
WINDOWS_X64_TARGET="scrypt-kdf-${VERSION}-windows-amd64.tgz"
WINDOWS_X64_TARGET_SIG=${WINDOWS_X64_TARGET}.sig
WINDOWS_X64_RELEASE="target/${WINDOWS_X64_TARGET}"
WINDOWS_X64_RELEASE_SIG=${WINDOWS_X64_RELEASE}.sig
tar zcvf ${WINDOWS_X64_RELEASE} target/x86_64-pc-windows-gnu/release/scrypt-kdf.exe
WINDOWS_X64_RELEASE_SHA512=$(shasum -a512 ${WINDOWS_X64_RELEASE})
gpg --output ${WINDOWS_X64_RELEASE_SIG} --detach-sig ${WINDOWS_X64_RELEASE}

RELEASE_NOTES="target/release.md"
echo "Preparing release notes..."

cat <<EOF >$RELEASE_NOTES
# Release Notes v${VERSION}
## Mac OS
## Mac OS ARM64
### SHA512
Calculate the SHA512:
\`\`\`bash
shasum -a512 ${APPLE_RELEASE} ${APPLE_RELEASE_SHA512}
\`\`\`sh
shasum -a512 ${APPLE_ARM64_RELEASE} ${APPLE_ARM64_RELEASE_SHA512}
\`\`\`
### Digital Signature
Verify the digital signature:
\`\`\`bash
gpg --verify ${APPLE_TARGET_SIG} ${APPLE_TARGET}
\`\`\`sh
gpg --verify ${APPLE_ARM64_TARGET_SIG} ${APPLE_ARM64_TARGET}
\`\`\`
## Mac OS x64
Calculate the SHA512:
\`\`\`sh
shasum -a512 ${APPLE_X64_RELEASE} ${APPLE_X64_RELEASE_SHA512}
\`\`\`
Verify the digital signature:
\`\`\`sh
gpg --verify ${APPLE_X64_TARGET_SIG} ${APPLE_X64_TARGET}
\`\`\`
## Linux AMD64
### SHA512
Calculate the SHA512:
\`\`\`sh
shasum -a512 ${LINUX_AMD64_RELEASE} ${LINUX_AMD64_RELEASE_SHA512}
\`\`\`
Verify the digital signature:
\`\`\`sh
gpg --verify ${LINUX_AMD64_TARGET_SIG} ${LINUX_AMD64_TARGET}
\`\`\`
## Windows x64
Calculate the SHA512:
\`\`\`bash
shasum -a512 ${LINUX_RELEASE} ${LINUX_RELEASE_SHA512}
\`\`\`sh
shasum -a512 ${WINDOWS_X64_RELEASE} ${WINDOWS_X64_RELEASE_SHA512}
\`\`\`
### Digital Signature
Verify the digital signature:
\`\`\`bash
gpg --verify ${LINUX_TARGET_SIG} ${LINUX_TARGET}
\`\`\`sh
gpg --verify ${WINDOWS_X64_TARGET_SIG} ${WINDOWS_X64_TARGET}
\`\`\`
EOF

0 comments on commit 83835db

Please sign in to comment.