Skip to content

Commit 482cada

Browse files
Prepare auto releases
1 parent e278dd0 commit 482cada

File tree

5 files changed

+177
-2
lines changed

5 files changed

+177
-2
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v2
1515

16+
- name: Cache build artifacts
17+
id: cache-cargo
18+
uses: actions/cache@v2
19+
with:
20+
path: |
21+
~/.cargo/bin
22+
~/.cargo/registry
23+
~/.cargo/git
24+
target
25+
key: build-${{ runner.os }}-cargo-any
26+
27+
- name: Install Rust toolchain
28+
uses: actions-rs/toolchain@v1
29+
with:
30+
toolchain: stable
31+
components: rustfmt
32+
override: true
33+
34+
- name: Verify versions
35+
run: rustc --version && rustup --version && cargo --version
36+
1637
- name: Get current tag
1738
id: current_tag
1839
uses: WyriHaximus/github-action-get-previous-tag@v1
@@ -22,12 +43,16 @@ jobs:
2243
env:
2344
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
2445

46+
- name: Release binaries
47+
run: ./scripts/release_binaries.sh --version=${{ steps.current_tag.outputs.tag }}
48+
2549
- name: Release new version
2650
uses: softprops/action-gh-release@v1
2751
with:
2852
tag_name: ${{ steps.current_tag.outputs.tag }}
2953
name: Sonic ${{ steps.current_tag.outputs.tag }}
3054
body: "⚠️ Changelog not yet provided."
55+
files: ./${{ steps.current_tag.outputs.tag }}-*.tar.gz
3156
env:
3257
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3358

PACKAGING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ We consider here the packaging flow of Sonic version `1.0.0` for Linux.
1212
2. **How to build Sonic, package it and release it on Crates, GitHub and Docker Hub (multiple architectures):**
1313
1. Tag the latest Git commit corresponding to the release with tag `v1.0.0`, and push the tag
1414
2. Wait for all release jobs to complete on the [actions](https://github.com/valeriansaliou/sonic/actions) page on GitHub
15-
3. Publish a changelog on the [releases](https://github.com/valeriansaliou/sonic/releases) page on GitHub
15+
3. Download all release archives, and sign them locally using: `./scripts/sign_binaries.sh --version=1.0.0`
16+
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

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ Sonic is integrated in all Crisp search products on the [Crisp](https://crisp.ch
5959

6060
### Installation
6161

62-
Sonic is built in Rust. To install it, use `cargo install` or pull the source code from `master`.
62+
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`.
63+
64+
👉 _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)._
6365

6466
**👉 Install from source:**
6567

scripts/release_binaries.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
##
4+
# Sonic
5+
#
6+
# Fast, lightweight and schema-less search backend
7+
# Copyright: 2023, Valerian Saliou <valerian@valeriansaliou.name>
8+
# License: Mozilla Public License v2.0 (MPL v2.0)
9+
##
10+
11+
# Read arguments
12+
while [ "$1" != "" ]; do
13+
argument_key=`echo $1 | awk -F= '{print $1}'`
14+
argument_value=`echo $1 | awk -F= '{print $2}'`
15+
16+
case $argument_key in
17+
-v | --version)
18+
# Notice: strip any leading 'v' to the version number
19+
SONIC_VERSION="${argument_value/v}"
20+
;;
21+
*)
22+
echo "Unknown argument received: '$argument_key'"
23+
exit 1
24+
;;
25+
esac
26+
27+
shift
28+
done
29+
30+
# Ensure release version is provided
31+
if [ -z "$SONIC_VERSION" ]; then
32+
echo "No Sonic release version was provided, please provide it using '--version'"
33+
34+
exit 1
35+
fi
36+
37+
# Define release pipeline
38+
function release_for_architecture {
39+
final_tar="v$SONIC_VERSION-$1-$2.tar.gz"
40+
41+
rm -rf ./sonic/ && \
42+
cargo build --target "$3" --release && \
43+
mkdir ./sonic && \
44+
cp -p "target/$3/release/sonic" ./sonic/ && \
45+
cp -r ./config.cfg sonic/ && \
46+
tar --owner=0 --group=0 -czvf "$final_tar" ./sonic && \
47+
rm -r ./sonic/
48+
release_result=$?
49+
50+
if [ $release_result -eq 0 ]; then
51+
echo "Result: Packed architecture: $1 ($2) to file: $final_tar"
52+
fi
53+
54+
return $release_result
55+
}
56+
57+
# Run release tasks
58+
ABSPATH=$(cd "$(dirname "$0")"; pwd)
59+
BASE_DIR="$ABSPATH/../"
60+
61+
rc=0
62+
63+
pushd "$BASE_DIR" > /dev/null
64+
echo "Executing release steps for Sonic v$SONIC_VERSION..."
65+
66+
release_for_architecture "x86_64" "gnu" "x86_64-unknown-linux-gnu"
67+
rc=$?
68+
69+
if [ $rc -eq 0 ]; then
70+
echo "Success: Done executing release steps for Sonic v$SONIC_VERSION"
71+
else
72+
echo "Error: Failed executing release steps for Sonic v$SONIC_VERSION"
73+
fi
74+
popd > /dev/null
75+
76+
exit $rc

scripts/sign_binaries.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
##
4+
# Sonic
5+
#
6+
# Fast, lightweight and schema-less search backend
7+
# Copyright: 2023, Valerian Saliou <valerian@valeriansaliou.name>
8+
# License: Mozilla Public License v2.0 (MPL v2.0)
9+
##
10+
11+
# Read arguments
12+
while [ "$1" != "" ]; do
13+
argument_key=`echo $1 | awk -F= '{print $1}'`
14+
argument_value=`echo $1 | awk -F= '{print $2}'`
15+
16+
case $argument_key in
17+
-v | --version)
18+
# Notice: strip any leading 'v' to the version number
19+
SONIC_VERSION="${argument_value/v}"
20+
;;
21+
*)
22+
echo "Unknown argument received: '$argument_key'"
23+
exit 1
24+
;;
25+
esac
26+
27+
shift
28+
done
29+
30+
# Ensure release version is provided
31+
if [ -z "$SONIC_VERSION" ]; then
32+
echo "No Sonic release version was provided, please provide it using '--version'"
33+
34+
exit 1
35+
fi
36+
37+
# Define sign pipeline
38+
function sign_for_architecture {
39+
final_tar="v$SONIC_VERSION-$1-$2.tar.gz"
40+
gpg_signer="valerian@valeriansaliou.name"
41+
42+
gpg -u "$gpg_signer" --armor --detach-sign "$final_tar"
43+
sign_result=$?
44+
45+
if [ $sign_result -eq 0 ]; then
46+
echo "Result: Signed architecture: $1 ($2) for file: $final_tar"
47+
fi
48+
49+
return $sign_result
50+
}
51+
52+
# Run sign tasks
53+
ABSPATH=$(cd "$(dirname "$0")"; pwd)
54+
BASE_DIR="$ABSPATH/../"
55+
56+
rc=0
57+
58+
pushd "$BASE_DIR" > /dev/null
59+
echo "Executing sign steps for Sonic v$SONIC_VERSION..."
60+
61+
sign_for_architecture "x86_64" "gnu"
62+
rc=$?
63+
64+
if [ $rc -eq 0 ]; then
65+
echo "Success: Done executing sign steps for Sonic v$SONIC_VERSION"
66+
else
67+
echo "Error: Failed executing sign steps for Sonic v$SONIC_VERSION"
68+
fi
69+
popd > /dev/null
70+
71+
exit $rc

0 commit comments

Comments
 (0)