Skip to content

Commit 8bf16cd

Browse files
Testing workflow changes
1 parent 5491677 commit 8bf16cd

File tree

6 files changed

+108
-62
lines changed

6 files changed

+108
-62
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function get_major_version() {
6+
echo "$1" | cut -d '.' -f 1
7+
}
8+
9+
function get_minor_version() {
10+
echo "$1" | cut -d '.' -f 2
11+
}
12+
13+
function trim_version() {
14+
grep -e "$1" "$2" | cut -d "=" -f 2 | tr -d "\"^ "
15+
}
16+
17+
function check_versions() {
18+
if [ "$1" != "$2" ]; then
19+
echo "aleph-bft Cargo's toml $3 version $1 different than README.md's $3 version $2!"
20+
exit 1
21+
fi
22+
}
23+
24+
cargo_toml_version=$(trim_version '^version =' "Cargo.toml")
25+
cargo_toml_major_version=$(get_major_version "${cargo_toml_version}")
26+
cargo_toml_minor_version=$(get_minor_version "${cargo_toml_version}")
27+
28+
readme_version=$(trim_version '\s*aleph-bft =' "README.md")
29+
readme_major_version=$(get_major_version "${readme_version}")
30+
readme_minor_version=$(get_minor_version "${readme_version}")
31+
32+
check_versions "${cargo_toml_major_version}" "${readme_major_version}" "major"
33+
check_versions "${cargo_toml_minor_version}" "${readme_minor_version}" "minor"
34+
echo "Versions from README and Cargo.toml match."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ -z "$(git diff HEAD origin/main -- src/)" ]; then
6+
echo "No changes in the code."
7+
exit 0
8+
fi
9+
10+
if [ -z "$(git diff HEAD origin/main -- Cargo.toml | grep '^+version =')" ]; then
11+
echo "None of commits in this PR has changed version in Cargo.toml!"
12+
exit 1
13+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Check if PR has bumbed versions in Cargo.toml for code changes and if README is synchronized
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-versions:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: check-cargo-toml-version-bumped
17+
run: ./.github/scripts/check-cargo-toml-version-bumped.sh
18+
shell: bash
19+
- name: cargo-toml-match-readme-version
20+
run: ./.github/scripts/cargo-toml-match-readme-version.sh
21+
shell: bash
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to crates.io
2+
3+
on:
4+
push:
5+
branches:
6+
main
7+
8+
jobs:
9+
publish:
10+
# need to rename environment name after this is merged
11+
environment: Autobump version
12+
runs-on: ubuntu-latest
13+
if: ${{ github.repository == 'Cardinal-Cryptography/AlephBFT'}}
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 2
19+
- name: force publish if version bumped
20+
run: |
21+
if [ -n "$(git diff HEAD~ -- Cargo.toml | grep '^+version =')" ]; then
22+
echo "Version in Cargo.toml was bumped in this PR, publishing to crates.io."
23+
touch publishMe
24+
fi
25+
- uses: actions-rs/toolchain@v1
26+
with:
27+
toolchain: stable
28+
- name: credentials
29+
uses: actions-rs/cargo@v1
30+
with:
31+
command: login
32+
args: ${{ secrets.CRATES_IO_TOKEN }}
33+
- name: publish
34+
run: |
35+
if [ -f publishMe ]; then
36+
echo "cargo publish"
37+
fi

.github/workflows/push-foundation-repo.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo
22

33
on:
4-
workflow_run:
5-
workflows: ["Autobump version"]
6-
branches: [main]
7-
types:
8-
- completed
4+
push:
5+
branches:
6+
main
97

108
jobs:
119
sync:

.github/workflows/version-bump.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)