Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
34 changes: 34 additions & 0 deletions .github/scripts/cargo-toml-match-readme-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

function get_major_version() {
echo "$1" | cut -d '.' -f 1
}

function get_minor_version() {
echo "$1" | cut -d '.' -f 2
}

function trim_version() {
grep -e "$1" "$2" | cut -d "=" -f 2 | tr -d "\"^ "
}

function check_versions() {
if [ "$1" != "$2" ]; then
echo "aleph-bft Cargo's toml $3 version $1 different than README.md's $3 version $2!"
exit 1
fi
}

cargo_toml_version=$(trim_version '^version =' "Cargo.toml")
cargo_toml_major_version=$(get_major_version "${cargo_toml_version}")
cargo_toml_minor_version=$(get_minor_version "${cargo_toml_version}")

readme_version=$(trim_version '\s*aleph-bft =' "README.md")
readme_major_version=$(get_major_version "${readme_version}")
readme_minor_version=$(get_minor_version "${readme_version}")

check_versions "${cargo_toml_major_version}" "${readme_major_version}" "major"
check_versions "${cargo_toml_minor_version}" "${readme_minor_version}" "minor"
echo "Versions from README and Cargo.toml match."
13 changes: 13 additions & 0 deletions .github/scripts/check-cargo-toml-version-bumped.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

if [ -z "$(git diff HEAD origin/main -- src/)" ]; then
echo "No changes in the code."
exit 0
fi

if [ -z "$(git diff HEAD origin/main -- Cargo.toml | grep '^+version =')" ]; then
echo "None of commits in this PR has changed version in Cargo.toml!"
exit 1
fi
21 changes: 21 additions & 0 deletions .github/workflows/check-version-bumped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check if PR has bumbed versions in Cargo.toml for code changes and if README is synchronized

on:
pull_request:
branches:
- main

jobs:
check-versions:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: check-cargo-toml-version-bumped
run: ./.github/scripts/check-cargo-toml-version-bumped.sh
shell: bash
- name: cargo-toml-match-readme-version
run: ./.github/scripts/cargo-toml-match-readme-version.sh
shell: bash
38 changes: 38 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish to crates.io

on:
push:
branches:
main

jobs:
publish:
# need to rename environment name after this is merged
environment: Autobump version
runs-on: ubuntu-latest
if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}}
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: force publish if version bumped
run: |
if [ -n "$(git diff HEAD~ -- Cargo.toml | grep '^+version =')" ]; then
echo "Version in Cargo.toml was bumped in this PR, publishing to crates.io."
touch publishMe
fi
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: credentials
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- name: publish
run: |
if [ -f publishMe ]; then
echo "Publishing to cargo.io"
cargo publish
fi
8 changes: 3 additions & 5 deletions .github/workflows/push-foundation-repo.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo

on:
workflow_run:
workflows: ["Autobump version"]
branches: [main]
types:
- completed
push:
branches:
main

jobs:
sync:
Expand Down
57 changes: 0 additions & 57 deletions .github/workflows/version-bump.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aleph-bft"
version = "0.8.2"
version = "0.8.3"
edition = "2018"
authors = ["Cardinal Cryptography"]
categories = ["algorithms", "data-structures", "cryptography", "database"]
Expand Down
3 changes: 3 additions & 0 deletions src/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub trait KeyBox: Index + Clone + Send + Sync + 'static {
pub trait PartialMultisignature: Signature {
type Signature: Signature;
/// Adds the signature.
#[must_use]
fn add_signature(self, signature: &Self::Signature, index: NodeIndex) -> Self;
}

Expand Down Expand Up @@ -408,6 +409,7 @@ impl<'a, T: Signable, MK: MultiKeychain> PartiallyMultisigned<'a, T, MK> {
}

/// Adds a signature and checks if multisignature is complete.
#[must_use]
pub fn add_signature(self, signed: Signed<'a, Indexed<T>, MK>, keychain: &'a MK) -> Self {
if self.as_signable().hash().as_ref() != signed.as_signable().hash().as_ref() {
warn!(target: "AlephBFT-signed", "Tried to add a signature of a different object");
Expand Down Expand Up @@ -440,6 +442,7 @@ pub type SignatureSet<S> = NodeMap<S>;
impl<S: Signature> PartialMultisignature for SignatureSet<S> {
type Signature = S;

#[must_use]
fn add_signature(mut self, signature: &Self::Signature, index: NodeIndex) -> Self {
self.insert(index, signature.clone());
self
Expand Down