Skip to content

Commit

Permalink
Prepare auto releases
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Sep 4, 2023
1 parent e278dd0 commit 482cada
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache build artifacts
id: cache-cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
target
key: build-${{ runner.os }}-cargo-any

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
override: true

- name: Verify versions
run: rustc --version && rustup --version && cargo --version

- name: Get current tag
id: current_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
Expand All @@ -22,12 +43,16 @@ jobs:
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

- name: Release binaries
run: ./scripts/release_binaries.sh --version=${{ steps.current_tag.outputs.tag }}

- name: Release new version
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.current_tag.outputs.tag }}
name: Sonic ${{ steps.current_tag.outputs.tag }}
body: "⚠️ Changelog not yet provided."
files: ./${{ steps.current_tag.outputs.tag }}-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
3 changes: 2 additions & 1 deletion PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ We consider here the packaging flow of Sonic version `1.0.0` for Linux.
2. **How to build Sonic, package it and release it on Crates, GitHub and Docker Hub (multiple architectures):**
1. Tag the latest Git commit corresponding to the release with tag `v1.0.0`, and push the tag
2. Wait for all release jobs to complete on the [actions](https://github.com/valeriansaliou/sonic/actions) page on GitHub
3. Publish a changelog on the [releases](https://github.com/valeriansaliou/sonic/releases) page on GitHub
3. Download all release archives, and sign them locally using: `./scripts/sign_binaries.sh --version=1.0.0`
4. Publish a changelog and upload all the built archives, as well as their signatures on the [releases](https://github.com/valeriansaliou/sonic/releases) page on GitHub
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Sonic is integrated in all Crisp search products on the [Crisp](https://crisp.ch

### Installation

Sonic is built in Rust. To install it, use `cargo install` or pull the source code from `master`.
Sonic is built in Rust. To install it, either download a version from the [Sonic releases](https://github.com/valeriansaliou/sonic/releases) page, use `cargo install` or pull the source code from `master`.

👉 _Each release binary comes with an `.asc` signature file, which can be verified using [@valeriansaliou](https://github.com/valeriansaliou) GPG public key: [:key:valeriansaliou.gpg.pub.asc](https://valeriansaliou.name/files/keys/valeriansaliou.gpg.pub.asc)._

**👉 Install from source:**

Expand Down
76 changes: 76 additions & 0 deletions scripts/release_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

##
# Sonic
#
# Fast, lightweight and schema-less search backend
# Copyright: 2023, Valerian Saliou <[email protected]>
# License: Mozilla Public License v2.0 (MPL v2.0)
##

# Read arguments
while [ "$1" != "" ]; do
argument_key=`echo $1 | awk -F= '{print $1}'`
argument_value=`echo $1 | awk -F= '{print $2}'`

case $argument_key in
-v | --version)
# Notice: strip any leading 'v' to the version number
SONIC_VERSION="${argument_value/v}"
;;
*)
echo "Unknown argument received: '$argument_key'"
exit 1
;;
esac

shift
done

# Ensure release version is provided
if [ -z "$SONIC_VERSION" ]; then
echo "No Sonic release version was provided, please provide it using '--version'"

exit 1
fi

# Define release pipeline
function release_for_architecture {
final_tar="v$SONIC_VERSION-$1-$2.tar.gz"

rm -rf ./sonic/ && \
cargo build --target "$3" --release && \
mkdir ./sonic && \
cp -p "target/$3/release/sonic" ./sonic/ && \
cp -r ./config.cfg sonic/ && \
tar --owner=0 --group=0 -czvf "$final_tar" ./sonic && \
rm -r ./sonic/
release_result=$?

if [ $release_result -eq 0 ]; then
echo "Result: Packed architecture: $1 ($2) to file: $final_tar"
fi

return $release_result
}

# Run release tasks
ABSPATH=$(cd "$(dirname "$0")"; pwd)
BASE_DIR="$ABSPATH/../"

rc=0

pushd "$BASE_DIR" > /dev/null
echo "Executing release steps for Sonic v$SONIC_VERSION..."

release_for_architecture "x86_64" "gnu" "x86_64-unknown-linux-gnu"
rc=$?

if [ $rc -eq 0 ]; then
echo "Success: Done executing release steps for Sonic v$SONIC_VERSION"
else
echo "Error: Failed executing release steps for Sonic v$SONIC_VERSION"
fi
popd > /dev/null

exit $rc
71 changes: 71 additions & 0 deletions scripts/sign_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

##
# Sonic
#
# Fast, lightweight and schema-less search backend
# Copyright: 2023, Valerian Saliou <[email protected]>
# License: Mozilla Public License v2.0 (MPL v2.0)
##

# Read arguments
while [ "$1" != "" ]; do
argument_key=`echo $1 | awk -F= '{print $1}'`
argument_value=`echo $1 | awk -F= '{print $2}'`

case $argument_key in
-v | --version)
# Notice: strip any leading 'v' to the version number
SONIC_VERSION="${argument_value/v}"
;;
*)
echo "Unknown argument received: '$argument_key'"
exit 1
;;
esac

shift
done

# Ensure release version is provided
if [ -z "$SONIC_VERSION" ]; then
echo "No Sonic release version was provided, please provide it using '--version'"

exit 1
fi

# Define sign pipeline
function sign_for_architecture {
final_tar="v$SONIC_VERSION-$1-$2.tar.gz"
gpg_signer="[email protected]"

gpg -u "$gpg_signer" --armor --detach-sign "$final_tar"
sign_result=$?

if [ $sign_result -eq 0 ]; then
echo "Result: Signed architecture: $1 ($2) for file: $final_tar"
fi

return $sign_result
}

# Run sign tasks
ABSPATH=$(cd "$(dirname "$0")"; pwd)
BASE_DIR="$ABSPATH/../"

rc=0

pushd "$BASE_DIR" > /dev/null
echo "Executing sign steps for Sonic v$SONIC_VERSION..."

sign_for_architecture "x86_64" "gnu"
rc=$?

if [ $rc -eq 0 ]; then
echo "Success: Done executing sign steps for Sonic v$SONIC_VERSION"
else
echo "Error: Failed executing sign steps for Sonic v$SONIC_VERSION"
fi
popd > /dev/null

exit $rc

0 comments on commit 482cada

Please sign in to comment.