diff --git a/.github/workflows/prepare-version-bump.yml b/.github/workflows/prepare-version-bump.yml new file mode 100644 index 00000000..ee164603 --- /dev/null +++ b/.github/workflows/prepare-version-bump.yml @@ -0,0 +1,50 @@ +name: Autobump version on PR + +on: + pull_request: + branches: + - main + +jobs: + prepare-new-version: + environment: Autobump version + runs-on: ubuntu-latest + if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}} + steps: + - name: cargo-next-install + run: | + cargo install cargo-next --locked + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 2 + ref: ${{ github.head_ref }} + token: ${{ secrets.SYNCAZF || secrets.MY_TOKEN || github.token }} + - name: check-and-bump + run: | + old_version=`cargo next --get` + # If version on PR branch and main branch have no differences in version -> bump it. + # Set version in README.md, commit, tag and push to PR branch. + # Assuming nominal version for us is the one in the top level Cargo.toml. + if ! git diff ${{ github.head_ref }} ${{ github.base_ref }} -- Cargo.toml | grep -q '^+version ='; then + echo "Version $old_version has NOT been changed manually between ${{ github.head_ref }} and ${{ github.base_ref }}, patching it now." + cargo next --patch + new_version=`cargo next --get` + echo "New version is $new_version." + git add Cargo.toml + fi + new_version=`cargo next --get` + # Make sure README has the same version as Cargo.toml. + sed -i "s/^version = \"$version\"$/version = \"$new_version\"/" Cargo.toml + git add README.md + # Publishing changes to PR branch + git config user.email "<>" + git config user.name "Version autobump" + git commit -m "Setting version to $new_version" + # Create tag with version if it not exist. + if ! git rev-parse "$new_version" >/dev/null 2>&1; then + git tag -a $new_version -m "Version $new_version created at PR ${{ github.head_ref }} -> ${{ github.base_ref }}" + fi + - name: push-to-PR + run: | + git push --follow-tags diff --git a/.github/workflows/push-foundation-repo.yml b/.github/workflows/push-foundation-repo.yml index 698e8fd0..400f1750 100644 --- a/.github/workflows/push-foundation-repo.yml +++ b/.github/workflows/push-foundation-repo.yml @@ -1,4 +1,4 @@ -name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo +name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo. on: workflow_run: diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index e7fe56c3..fa533d94 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -1,9 +1,15 @@ name: Autobump version on: - push: - branches: - - main + workflow_dispatch: + # NOTE: changed to "manual workflow dispatch" for now. + # TODO: To be automated again, when workflows stabilize + # and pushes to main origin will be forbidden. + # push: + # branches: + # - main + + jobs: autobump: @@ -11,37 +17,6 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}} steps: - - name: checkout - uses: actions/checkout@v2 - with: - fetch-depth: 2 - - name: bump - run: | - version=`grep -e '^version =' Cargo.toml | sed 's/version = //' | sed 's/"//g'` - major_version=`echo $version|grep -o -e '^[0-9]*'` - minor_version=`echo $version|grep -o -e '^[0-9]*.[0-9]*'|grep -o -e '[0-9]*$'` - patch_version=`echo $version|grep -o -e '[0-9]*$'` - git config user.email "<>" - git config user.name "Version autobump" - if git diff HEAD~ -- Cargo.toml | grep -q '^+version ='; then - echo 'Version has been bumped manually, bumping readme version and uploading to crates.io' - new_version=$major_version.$minor_version - sed -i "s/aleph-bft = \"\^[0-9]*.[0-9]*\"$/aleph-bft = \"^$new_version\"/" README.md - git add README.md - git commit --amend --no-edit - git push -f origin main - touch publishMe - exit 0 - fi - if [ -e `git diff HEAD~ -- src/` ]; then - echo 'No changes in code.' - exit 0 - fi - new_version=$major_version.$minor_version.$((patch_version + 1)) - sed -i "s/^version = \"$version\"$/version = \"$new_version\"/" Cargo.toml - git add Cargo.toml - git commit --amend --no-edit - git push -f origin main - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -52,6 +27,6 @@ jobs: args: ${{ secrets.CRATES_IO_TOKEN }} - name: publish run: | - if [ -f publishMe ]; then - cargo publish - fi + echo 'Uploading to crates.io' + cargo publish + diff --git a/Cargo.lock b/Cargo.lock index 773a361b..c2aa0602 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "aleph-bft" -version = "0.8.0" +version = "0.8.3" dependencies = [ "async-trait", "bit-vec", diff --git a/Cargo.toml b/Cargo.toml index c2da0e47..f088906c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"]