From 968582ee155ab1a584e20cc11a2d7ace63ff1f84 Mon Sep 17 00:00:00 2001 From: plebhash Date: Thu, 29 Feb 2024 15:41:28 +0000 Subject: [PATCH 01/17] release-libs on push to main --- .github/workflows/release-libs.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index c31cfdde0..d21b54439 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -10,9 +10,10 @@ name: Release Libs -on: - # Manually run by going to "Actions/Release" in Github and running the workflow - workflow_dispatch: +on: + push: + branches: + - main jobs: libs_publish: From 26b9792fdec5920bc2d06dffaeea82461cd17e61 Mon Sep 17 00:00:00 2001 From: plebhash Date: Fri, 15 Mar 2024 18:34:50 -0300 Subject: [PATCH 02/17] add check-versioning-lib-release.sh --- check-versioning-lib-release.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 check-versioning-lib-release.sh diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh new file mode 100755 index 000000000..a0a006375 --- /dev/null +++ b/check-versioning-lib-release.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Get the list of paths to `Cargo.toml` files +crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) + +# Filter out crates that are not published to crates.io +filter=("benches" "examples" "test") +for f in "${filter[@]}"; do + crates=$(echo "$crates" | grep -v "$f") +done + +# Loop through each crate, while avoiding root workspace Cargo.toml +for crate in $crates; do + if [ "$crate" != "./protocols" ] && [ "$crate" != "./common" ] && [ "$crate" != "./roles" ] && [ "$crate" != "./utils" ]; then + cd "$crate" + + # Check if there were any changes between dev and main + git diff --quiet "dev" "main" -- . + if [ $? -ne 0 ]; then + + # Check if crate versions on dev and main are identical + version_dev=$(git show dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + version_main=$(git show main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + if [ "$version_dev" = "$version_main" ]; then + echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main." + exit 1 + fi + fi + + cd - >/dev/null + fi +done \ No newline at end of file From a3059852d0a1f70426b369bd74dde8cb60cb1089 Mon Sep 17 00:00:00 2001 From: plebhash Date: Thu, 21 Mar 2024 22:01:05 -0300 Subject: [PATCH 03/17] avoid files under target dir --- check-versioning-lib-release.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index a0a006375..9937199f6 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -9,9 +9,14 @@ for f in "${filter[@]}"; do crates=$(echo "$crates" | grep -v "$f") done -# Loop through each crate, while avoiding root workspace Cargo.toml +# Loop through each crate, while avoiding root workspace Cargo.toml and files under `target` directory for crate in $crates; do - if [ "$crate" != "./protocols" ] && [ "$crate" != "./common" ] && [ "$crate" != "./roles" ] && [ "$crate" != "./utils" ]; then + if [ "$crate" != "./protocols" ] && \ + [ "$crate" != "./common" ] && \ + [ "$crate" != "./roles" ] && \ + [ "$crate" != "./utils" ] && \ + ! echo "$crate" | grep -q "target"; then + cd "$crate" # Check if there were any changes between dev and main From d6ac08942bd9574afbbc22bc4c5f75126e60260a Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 14:40:39 -0300 Subject: [PATCH 04/17] remove roles from release-libs.yaml --- .github/workflows/release-libs.yaml | 22 +--------------------- check-versioning-lib-release.sh | 2 +- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index d21b54439..21038ecf4 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -135,24 +135,4 @@ jobs: continue-on-error: true run: | cd roles/roles-utils/rpc - cargo publish - - name: Publish crate jd_client - continue-on-error: true - run: | - cargo publish --manifest-path=roles/jd-client/Cargo.toml - - name: Publish crate jd_server - continue-on-error: true - run: | - cargo publish --manifest-path=roles/jd-server/Cargo.toml - - name: Publish crate mining_proxy_sv2 - continue-on-error: true - run: | - cargo publish --manifest-path=roles/mining-proxy/Cargo.toml - - name: Publish crate pool_sv2 - continue-on-error: true - run: | - cargo publish --manifest-path=roles/pool/Cargo.toml - - name: Publish crate translator_sv2 - continue-on-error: true - run: | - cargo publish --manifest-path=roles/translator/Cargo.toml \ No newline at end of file + cargo publish \ No newline at end of file diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index 9937199f6..6b142d378 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -4,7 +4,7 @@ crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) # Filter out crates that are not published to crates.io -filter=("benches" "examples" "test") +filter=("benches" "examples" "test" "roles") for f in "${filter[@]}"; do crates=$(echo "$crates" | grep -v "$f") done From 1f149dc7f1d5c1a0f6d37add34bb663584a24929 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 14:52:36 -0300 Subject: [PATCH 05/17] run check-versioning-lib-release.sh on CI --- .github/workflows/release-libs.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 21038ecf4..20e593403 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -16,6 +16,18 @@ on: - main jobs: + check_versioning_lib_release: + runs-on: ubuntu-latest + steps: + - name: run check-versioning-lib-release.sh + - uses: actions/checkout@v3 + run: | + ./check-versioning-lib-release.sh + if [ $? -eq 1 ]; then + echo "Script returned exit code 1, halting the workflow" + exit 1 + fi + libs_publish: runs-on: ubuntu-latest steps: From abfc5da343ae2cad9249f0aa1ecdaa7fba8a9d53 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 15:15:27 -0300 Subject: [PATCH 06/17] fix release-libs.yaml --- .github/workflows/release-libs.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 20e593403..9789608a5 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -19,8 +19,10 @@ jobs: check_versioning_lib_release: runs-on: ubuntu-latest steps: - - name: run check-versioning-lib-release.sh - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run check-versioning-lib-release.sh run: | ./check-versioning-lib-release.sh if [ $? -eq 1 ]; then From e4f8db8475c4f0ef2dba24fac62ca39be5fd2ab9 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 15:52:16 -0300 Subject: [PATCH 07/17] use bash shebang on check-versioning-lib-release.sh --- check-versioning-lib-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index 6b142d378..0ef1d5800 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Get the list of paths to `Cargo.toml` files crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) From b57352b283931528666594f1e03052ab21c54afb Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 17:14:29 -0300 Subject: [PATCH 08/17] unify jobs --- .github/workflows/release-libs.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 9789608a5..d94cc5e64 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -16,7 +16,7 @@ on: - main jobs: - check_versioning_lib_release: + libs_publish: runs-on: ubuntu-latest steps: - name: Checkout code @@ -30,14 +30,11 @@ jobs: exit 1 fi - libs_publish: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: - toolchain: stable - override: true + toolchain: stable + override: true - name: Login run: cargo login ${{ secrets.CRATES_IO_DEPLOY_KEY }} - name: Publish crate common From 32f47eac38118c658b6c818e9a6bbab3da77c087 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 17:18:51 -0300 Subject: [PATCH 09/17] fix check-versioning-lib-release.sh --- check-versioning-lib-release.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index 0ef1d5800..b78c31412 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -5,27 +5,36 @@ crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) # Filter out crates that are not published to crates.io filter=("benches" "examples" "test" "roles") -for f in "${filter[@]}"; do - crates=$(echo "$crates" | grep -v "$f") +for crate in $crates; do + filtered=false + for f in "${filter[@]}"; do + if [ "$crate" = "./$f" ]; then + filtered=true + break + fi + done + if [ "$filtered" = false ]; then + filtered_crates+=("$crate") + fi done +crates="${filtered_crates[@]}" + # Loop through each crate, while avoiding root workspace Cargo.toml and files under `target` directory for crate in $crates; do if [ "$crate" != "./protocols" ] && \ [ "$crate" != "./common" ] && \ - [ "$crate" != "./roles" ] && \ - [ "$crate" != "./utils" ] && \ ! echo "$crate" | grep -q "target"; then cd "$crate" # Check if there were any changes between dev and main - git diff --quiet "dev" "main" -- . + git diff --quiet "origin/dev" "origin/main" -- . if [ $? -ne 0 ]; then # Check if crate versions on dev and main are identical - version_dev=$(git show dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') - version_main=$(git show main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + version_dev=$(git show origin/dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + version_main=$(git show origin/main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') if [ "$version_dev" = "$version_main" ]; then echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main." exit 1 From 8d6e7f179a05e7ba08045225b8b64c1f2c9db396 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 17:47:16 -0300 Subject: [PATCH 10/17] trigger release-libs.yaml on pull_requests to main --- .github/workflows/release-libs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index d94cc5e64..b16908d47 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -11,7 +11,7 @@ name: Release Libs on: - push: + pull_request: branches: - main From 475cdd6367025072a67f94d570e0425d2fc41851 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 17:58:08 -0300 Subject: [PATCH 11/17] checkout main on release-libs.yaml --- .github/workflows/release-libs.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index b16908d47..53b258611 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -11,7 +11,7 @@ name: Release Libs on: - pull_request: + push: branches: - main @@ -21,6 +21,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + with: + ref: 'main' - name: Run check-versioning-lib-release.sh run: | From f887e3d244c6bd7b18937ed6f25ea43153494c05 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 18:18:06 -0300 Subject: [PATCH 12/17] revert checkout main on release-libs.yaml --- .github/workflows/release-libs.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 53b258611..d94cc5e64 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -21,8 +21,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 - with: - ref: 'main' - name: Run check-versioning-lib-release.sh run: | From c5bf950d6057455c4df6dc00364c5920812f7607 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 18:18:23 -0300 Subject: [PATCH 13/17] fetch main and dev branches --- check-versioning-lib-release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index b78c31412..853f61996 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -1,5 +1,8 @@ #!/bin/bash +git fetch origin main +git fetch origin dev + # Get the list of paths to `Cargo.toml` files crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) From 911115786fc9a11053672d615fdb80b9aa0bb75d Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 18:35:35 -0300 Subject: [PATCH 14/17] trigger release-libs.yaml on pull_requests to main --- .github/workflows/release-libs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index d94cc5e64..b16908d47 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -11,7 +11,7 @@ name: Release Libs on: - push: + pull_request: branches: - main From 86c7c10b204747530555aa53c27bb9a764f5318b Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 19:31:39 -0300 Subject: [PATCH 15/17] simplify check-versioning-lib-release.sh --- check-versioning-lib-release.sh | 88 +++++++++++++++++---------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index 853f61996..ff5c7db0d 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -3,47 +3,49 @@ git fetch origin main git fetch origin dev -# Get the list of paths to `Cargo.toml` files -crates=$(find . -name Cargo.toml -exec dirname {} \; | sort) - -# Filter out crates that are not published to crates.io -filter=("benches" "examples" "test" "roles") -for crate in $crates; do - filtered=false - for f in "${filter[@]}"; do - if [ "$crate" = "./$f" ]; then - filtered=true - break - fi - done - if [ "$filtered" = false ]; then - filtered_crates+=("$crate") - fi -done - -crates="${filtered_crates[@]}" - -# Loop through each crate, while avoiding root workspace Cargo.toml and files under `target` directory -for crate in $crates; do - if [ "$crate" != "./protocols" ] && \ - [ "$crate" != "./common" ] && \ - ! echo "$crate" | grep -q "target"; then - - cd "$crate" - - # Check if there were any changes between dev and main - git diff --quiet "origin/dev" "origin/main" -- . - if [ $? -ne 0 ]; then - - # Check if crate versions on dev and main are identical - version_dev=$(git show origin/dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') - version_main=$(git show origin/main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') - if [ "$version_dev" = "$version_main" ]; then - echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main." - exit 1 - fi - fi - - cd - >/dev/null - fi +# this list was taken from `.github/workflows/release-libs.yaml`. +# if anything changes there (crates added/removed to publishing pipeline) +# those changes should be reflected here +crates=( +"utils/buffer" +"protocols/v2/binary-sv2/no-serde-sv2/derive_codec" +"protocols/v2/binary-sv2/no-serde-sv2/codec" +"protocols/v2/binary-sv2/serde-sv2" +"protocols/v2/binary-sv2/binary-sv2" +"protocols/v2/const-sv2" +"protocols/v2/framing-sv2" +"protocols/v2/noise-sv2" +"protocols/v2/codec-sv2" +"protocols/v2/subprotocols/common-messages" +"protocols/v2/subprotocols/job-declaration" +"protocols/v2/subprotocols/mining" +"protocols/v2/subprotocols/template-distribution" +"protocols/v2/sv2-ffi" +"protocols/v2/roles-logic-sv2" +"protocols/v1" +"utils/bip32-key-derivation" +"utils/error-handling" +"utils/key-utils" +"roles/roles-utils/network-helpers" +"roles/roles-utils/rpc" +) + +# Loop through each crate +for crate in "${crates[@]}"; do + cd "$crate" + + # Check if there were any changes between dev and main + git diff --quiet "origin/dev" "origin/main" -- . + if [ $? -ne 0 ]; then + + # Check if crate versions on dev and main are identical + version_dev=$(git show origin/dev:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + version_main=$(git show origin/main:./Cargo.toml | awk -F' = ' '$1 == "version" {gsub(/[ "]+/, "", $2); print $2}') + if [ "$version_dev" = "$version_main" ]; then + echo "Changes detected in crate $crate between dev and main branches! Versions on dev and main branches are identical ($version_dev), so you should bump the crate version on dev before merging into main." + exit 1 + fi + fi + + cd - >/dev/null done \ No newline at end of file From 2ca3bf0a51a7699771120c38a23397005916f713 Mon Sep 17 00:00:00 2001 From: plebhash Date: Tue, 2 Apr 2024 19:39:44 -0300 Subject: [PATCH 16/17] lint release-libs.yaml --- .github/workflows/release-libs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index b16908d47..41c46aa86 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -33,8 +33,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 with: - toolchain: stable - override: true + toolchain: stable + override: true - name: Login run: cargo login ${{ secrets.CRATES_IO_DEPLOY_KEY }} - name: Publish crate common From 52098db554d5fe6b0d8db93c53bdc276f9a064b2 Mon Sep 17 00:00:00 2001 From: plebhash Date: Wed, 3 Apr 2024 12:35:19 -0300 Subject: [PATCH 17/17] Revert "remove roles from release-libs.yaml" This reverts commit d6ac08942bd9574afbbc22bc4c5f75126e60260a. --- .github/workflows/release-libs.yaml | 25 +++++++++++++++++++++++++ check-versioning-lib-release.sh | 8 +++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 41c46aa86..9ab285ef4 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -146,4 +146,29 @@ jobs: continue-on-error: true run: | cd roles/roles-utils/rpc + cargo publish + - name: Publish crate jd_client + continue-on-error: true + run: | + cd roles/jd-client + cargo publish + - name: Publish crate jd_server + continue-on-error: true + run: | + cd roles/jd-server + cargo publish + - name: Publish crate mining_proxy_sv2 + continue-on-error: true + run: | + cd roles/mining-proxy + cargo publish + - name: Publish crate pool_sv2 + continue-on-error: true + run: | + cd roles/pool + cargo publish + - name: Publish crate translator_sv2 + continue-on-error: true + run: | + cd roles/translator cargo publish \ No newline at end of file diff --git a/check-versioning-lib-release.sh b/check-versioning-lib-release.sh index ff5c7db0d..6d2bcc794 100755 --- a/check-versioning-lib-release.sh +++ b/check-versioning-lib-release.sh @@ -3,9 +3,6 @@ git fetch origin main git fetch origin dev -# this list was taken from `.github/workflows/release-libs.yaml`. -# if anything changes there (crates added/removed to publishing pipeline) -# those changes should be reflected here crates=( "utils/buffer" "protocols/v2/binary-sv2/no-serde-sv2/derive_codec" @@ -28,6 +25,11 @@ crates=( "utils/key-utils" "roles/roles-utils/network-helpers" "roles/roles-utils/rpc" +"roles/jd-client" +"roles/jd-server" +"roles/mining-proxy" +"roles/pool" +"roles/translator" ) # Loop through each crate