From 95b76596689db6a1975b3874fedea26a09a0033c Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 20:58:31 +0200 Subject: [PATCH 01/19] Add job to build for the win-msvc target. --- .../workflows/build-and-publish-bindings.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index 003aea69a..afb8328cf 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -78,6 +78,27 @@ jobs: name: ldk-node-x86_64-pc-windows-gnu path: target/x86_64-pc-windows-gnu/release/ldk_node.dll + build-windows-msvc: + runs-on: windows-2019 + steps: + - name: Set up Rust + run: | + rustup toolchain install ${{ env.RUST_VERSION }} + rustup target add x86_64-pc-windows-msvc + rustup default ${{ env.RUST_VERSION }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Windows x64_64 + run: cargo build --release --target x86_64-pc-windows-msvc --features uniffi + + - name: Archive Windows x86_64 + uses: actions/upload-artifact@v4 + with: + name: ldk-node-x86_64-pc-windows-msvc + path: target/x86_64-pc-windows-msvc/release/ldk_node.dll + build-macos: runs-on: macos-12 steps: From 3804f27dc7c6a81f2c849143aefaabe4cacedf5e Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 21:13:27 +0200 Subject: [PATCH 02/19] Publish Win-MSVC DLLs. --- .github/workflows/build-and-publish-bindings.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index afb8328cf..ffab74ced 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -161,12 +161,18 @@ jobs: name: ldk-node-arm-unknown-linux-gnueabihf path: ldk_node/arm-unknown-linux-gnueabihf - - name: Download Windows x86_64 libs + - name: Download Windows x86_64 GNU libs uses: actions/download-artifact@v4 with: name: ldk-node-x86_64-pc-windows-gnu path: ldk_node/x86_64-pc-windows-gnu + - name: Download Windows x86_64 MSVC libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-x86_64-pc-windows-msvc + path: ldk_node/x86_64-pc-windows-msvc + - name: Download macOS libs uses: actions/download-artifact@v4 with: @@ -185,6 +191,7 @@ jobs: git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so git add ldk_node/x86_64-pc-windows-gnu/ldk_node.dll + git add ldk_node/x86_64-pc-windows-msvc/ldk_node.dll git add ldk_node/universal-macos/libldk_node.dylib git commit -m "Update bindings." From 69b41bdfa87f147c4b33a1b4bac42bade673b924 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 21:29:08 +0200 Subject: [PATCH 03/19] Pull updates from the branch after checking it out. --- .github/workflows/build-and-publish-bindings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index ffab74ced..03edf0a46 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -187,6 +187,7 @@ jobs: if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} fi + git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so From e7d0e55faccb135593e38fa45e1af6e63d2c5a26 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 22:40:35 +0200 Subject: [PATCH 04/19] Restructure the workflow: split into files. --- .../workflows/build-and-publish-bindings.yml | 201 ++---------------- .github/workflows/build-libraries.yaml | 75 +++++++ .github/workflows/gen-bindings-go.yaml | 35 +++ .github/workflows/publish-bindings-go.yaml | 78 +++++++ 4 files changed, 201 insertions(+), 188 deletions(-) create mode 100644 .github/workflows/build-libraries.yaml create mode 100644 .github/workflows/gen-bindings-go.yaml create mode 100644 .github/workflows/publish-bindings-go.yaml diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index 03edf0a46..b23c51dc9 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -7,197 +7,22 @@ on: env: RUST_VERSION: 1.78 - LDK_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - TARGET_BRANCH_PREFIX: "publish-" jobs: - uniffi-bindings: - runs-on: ubuntu-20.04 - steps: - - name: Set up Rust - run: | - rustup toolchain install ${{ env.RUST_VERSION }} - rustup default ${{ env.RUST_VERSION }} + generate-bindings: + uses: ./.github/workflows/gen-bindings-go.yaml + with: + rust_version: ${{ env.RUST_VERSION }} - - name: Checkout - uses: actions/checkout@v4 - - - name: Install uniffi-bindgen-go - run: cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0 - - - name: Generate bindings - run: uniffi-bindgen-go bindings/ldk_node.udl -o ffi/golang -c ./uniffi.toml - - - name: Archive bindings - uses: actions/upload-artifact@v4 - with: - name: ldk-node-bindings - path: | - ffi/golang/ldk_node/ldk_node.go - ffi/golang/ldk_node/ldk_node.h - ffi/golang/ldk_node/ldk_node.c - - build-linux-windows: - runs-on: ubuntu-20.04 - steps: - - name: Set up Rust - run: | - rustup toolchain install ${{ env.RUST_VERSION }} - rustup default ${{ env.RUST_VERSION }} - - - name: Install cross - run: cargo install cross --git https://github.com/cross-rs/cross --rev c87a52a - - - name: Checkout - uses: actions/checkout@v4 - - - name: Build Linux x86_64 - run: cross build --release --target x86_64-unknown-linux-gnu --features uniffi - - - name: Build Linux ARM - run: cross build --release --target arm-unknown-linux-gnueabihf --features uniffi - - - name: Build Windows x64_64 - run: cross build --release --target x86_64-pc-windows-gnu --features uniffi - - - name: Archive Linux x86_64 - uses: actions/upload-artifact@v4 - with: - name: ldk-node-x86_64-unknown-linux-gnu - path: target/x86_64-unknown-linux-gnu/release/libldk_node.so - - - name: Archive Linux ARM - uses: actions/upload-artifact@v4 - with: - name: ldk-node-arm-unknown-linux-gnueabihf - path: target/arm-unknown-linux-gnueabihf/release/libldk_node.so - - - name: Archive Windows x86_64 - uses: actions/upload-artifact@v4 - with: - name: ldk-node-x86_64-pc-windows-gnu - path: target/x86_64-pc-windows-gnu/release/ldk_node.dll - - build-windows-msvc: - runs-on: windows-2019 - steps: - - name: Set up Rust - run: | - rustup toolchain install ${{ env.RUST_VERSION }} - rustup target add x86_64-pc-windows-msvc - rustup default ${{ env.RUST_VERSION }} - - - name: Checkout - uses: actions/checkout@v4 - - - name: Build Windows x64_64 - run: cargo build --release --target x86_64-pc-windows-msvc --features uniffi - - - name: Archive Windows x86_64 - uses: actions/upload-artifact@v4 - with: - name: ldk-node-x86_64-pc-windows-msvc - path: target/x86_64-pc-windows-msvc/release/ldk_node.dll - - build-macos: - runs-on: macos-12 - steps: - - name: Set up Rust - run: | - rustup toolchain install ${{ env.RUST_VERSION }} - rustup default ${{ env.RUST_VERSION }} - rustup target add aarch64-apple-darwin - rustup target add x86_64-apple-darwin - - - name: Checkout - uses: actions/checkout@v4 - - - name: Build macOS x86_64 - run: cargo build --release --target x86_64-apple-darwin --features uniffi - - - name: Build macOS ARM64 - run: cargo build --release --target aarch64-apple-darwin --features uniffi - - - name: Make universal macOS library - run: | - mkdir -p target/universal-macos/release - lipo -create -output "target/universal-macos/release/libldk_node.dylib" "target/aarch64-apple-darwin/release/libldk_node.dylib" "target/x86_64-apple-darwin/release/libldk_node.dylib" - - - name: Archive macOS - uses: actions/upload-artifact@v4 - with: - name: ldk-node-universal-macos - path: target/universal-macos/release/libldk_node.dylib + build-libraries: + uses: ./.github/workflows/build-libraries.yaml + with: + rust_version: ${{ env.RUST_VERSION }} publish-ldk-node-go: needs: - - uniffi-bindings - - build-linux-windows - - build-macos - runs-on: ubuntu-20.04 - - steps: - - name: Checkout ldk-node-go - uses: actions/checkout@v4 - with: - repository: getAlby/ldk-node-go - ssh-key: ${{ secrets.LDK_NODE_GO_DEPLOY_KEY }} - - - name: Download bindings - uses: actions/download-artifact@v4 - with: - name: ldk-node-bindings - path: ldk_node - - - name: Download Linux x86_64 libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-x86_64-unknown-linux-gnu - path: ldk_node/x86_64-unknown-linux-gnu - - - name: Download Linux ARM libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-arm-unknown-linux-gnueabihf - path: ldk_node/arm-unknown-linux-gnueabihf - - - name: Download Windows x86_64 GNU libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-x86_64-pc-windows-gnu - path: ldk_node/x86_64-pc-windows-gnu - - - name: Download Windows x86_64 MSVC libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-x86_64-pc-windows-msvc - path: ldk_node/x86_64-pc-windows-msvc - - - name: Download macOS libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-universal-macos - path: ldk_node/universal-macos - - - name: Commit and push bindings - run: | - git config --global user.email "github-actions@github.com" - git config --global user.name "github-actions" - git config --global push.autoSetupRemote true - if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - fi - git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true - git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c - git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so - git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so - git add ldk_node/x86_64-pc-windows-gnu/ldk_node.dll - git add ldk_node/x86_64-pc-windows-msvc/ldk_node.dll - git add ldk_node/universal-macos/libldk_node.dylib - git commit -m "Update bindings." - - if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - else - git push origin master - fi + - generate-bindings + - build-libraries + uses: ./.github/workflows/publish-bindings-go.yaml + secrets: + LDK_NODE_GO_DEPLOY_KEY: ${{ secrets.LDK_NODE_GO_DEPLOY_KEY }} diff --git a/.github/workflows/build-libraries.yaml b/.github/workflows/build-libraries.yaml new file mode 100644 index 000000000..8c4bd7a5f --- /dev/null +++ b/.github/workflows/build-libraries.yaml @@ -0,0 +1,75 @@ +name: Build libraries for all targets + +on: + workflow_call: + inputs: + rust_version: + required: true + type: string + +jobs: + build: + strategy: + matrix: + build: [ + { host: ubuntu-20.04, tool: cargo, target: x86_64-unknown-linux-gnu, output: libldk_node.so }, + { host: ubuntu-20.04, tool: cross, target: arm-unknown-linux-gnueabihf, output: libldk_node.so }, + { host: windows-2019, tool: cargo, target: x86_64-pc-windows-msvc, output: ldk_node.dll }, + { host: macos-12, tool: cargo, target: x86_64-apple-darwin, output: libldk_node.dylib }, + { host: macos-12, tool: cargo, target: aarch64-apple-darwin, output: libldk_node.dylib }, + ] + runs-on: ${{ matrix.build.host }} + steps: + - name: Set up Rust + run: | + rustup toolchain install ${{ inputs.rust_version }} + rustup default ${{ inputs.rust_version }} + + - name: Add target + if: '${{ matrix.build.tool }}' == 'cargo' + run: rustup target add ${{ matrix.target }} + + - name: Install cross + if: '${{ matrix.build.tool }}' == 'cross' + run: cargo install cross --git https://github.com/cross-rs/cross --rev c87a52a + + - name: Checkout + uses: actions/checkout@v4 + + - name: Build + run: ${{ matrix.build.tool }} build --release --target ${{ matrix.build.target }} --features uniffi + + - name: Archive + uses: actions/upload-artifact@v4 + with: + name: ldk-node-${{ matrix.build.target }} + path: target/${{ matrix.build.target }}/release/${{ matrix.build.output }} + + make-macos-universal: + runs-on: macos-12 + needs: build + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download macOS artifacts + uses: actions/download-artifact@v4 + with: + name: ldk-node-x86_64-apple-darwin + path: x86_64-apple-darwin/libldk_node.dylib + + - name: Download macOS artifacts + uses: actions/download-artifact@v4 + with: + name: ldk-node-aarch64-apple-darwin + path: aarch64-apple-darwin/libldk_node.dylib + + - name: Make universal library + run: | + lipo -create -output "libldk_node.dylib" "x86_64-apple-darwin/libldk_node.dylib" "aarch64-apple-darwin/libldk_node.dylib" + + - name: Archive universal library + uses: actions/upload-artifact@v4 + with: + name: ldk-node-universal-apple-darwin + path: libldk_node.dylib diff --git a/.github/workflows/gen-bindings-go.yaml b/.github/workflows/gen-bindings-go.yaml new file mode 100644 index 000000000..07a421a5a --- /dev/null +++ b/.github/workflows/gen-bindings-go.yaml @@ -0,0 +1,35 @@ +name: Generate Go bindings + +on: + workflow_call: + inputs: + rust_version: + required: true + type: string + +jobs: + uniffi-bindings: + runs-on: ubuntu-20.04 + steps: + - name: Set up Rust + run: | + rustup toolchain install ${{ inputs.rust_version }} + rustup default ${{ inputs.rust_version }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Install uniffi-bindgen-go + run: cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0 + + - name: Generate bindings + run: uniffi-bindgen-go bindings/ldk_node.udl -o ffi/golang -c ./uniffi.toml + + - name: Archive bindings + uses: actions/upload-artifact@v4 + with: + name: ldk-node-bindings + path: | + ffi/golang/ldk_node/ldk_node.go + ffi/golang/ldk_node/ldk_node.h + ffi/golang/ldk_node/ldk_node.c diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml new file mode 100644 index 000000000..51cce6e31 --- /dev/null +++ b/.github/workflows/publish-bindings-go.yaml @@ -0,0 +1,78 @@ +name: Build libraries for all targets + +on: + workflow_call: + +env: + LDK_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + TARGET_BRANCH_PREFIX: "publish-" + +jobs: + publish-ldk-node-go: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout ldk-node-go + uses: actions/checkout@v4 + with: + repository: getAlby/ldk-node-go + ssh-key: ${{ secrets.LDK_NODE_GO_DEPLOY_KEY }} + + - name: Download bindings + uses: actions/download-artifact@v4 + with: + name: ldk-node-bindings + path: ldk_node + + - name: Download Linux x86_64 libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-x86_64-unknown-linux-gnu + path: ldk_node/x86_64-unknown-linux-gnu + + - name: Download Linux ARM libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-arm-unknown-linux-gnueabihf + path: ldk_node/arm-unknown-linux-gnueabihf + + - name: Download Windows x86_64 GNU libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-x86_64-pc-windows-gnu + path: ldk_node/x86_64-pc-windows-gnu + + - name: Download Windows x86_64 MSVC libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-x86_64-pc-windows-msvc + path: ldk_node/x86_64-pc-windows-msvc + + - name: Download macOS libs + uses: actions/download-artifact@v4 + with: + name: ldk-node-universal-apple-darwin + path: ldk_node/universal-macos + + - name: Commit and push bindings + run: | + git config --global user.email "github-actions@github.com" + git config --global user.name "github-actions" + git config --global push.autoSetupRemote true + if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then + git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + fi + git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true + git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c + git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so + git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so + git add ldk_node/x86_64-pc-windows-gnu/ldk_node.dll + git add ldk_node/x86_64-pc-windows-msvc/ldk_node.dll + git add ldk_node/universal-macos/libldk_node.dylib + git commit -m "Update bindings." + + if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then + git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + else + git push origin master + fi From c6501807d1017bb8ab30288682c61910f40fc79b Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 22:45:20 +0200 Subject: [PATCH 05/19] Fix syntax error. --- .github/workflows/build-libraries.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-libraries.yaml b/.github/workflows/build-libraries.yaml index 8c4bd7a5f..377ed83b9 100644 --- a/.github/workflows/build-libraries.yaml +++ b/.github/workflows/build-libraries.yaml @@ -26,11 +26,11 @@ jobs: rustup default ${{ inputs.rust_version }} - name: Add target - if: '${{ matrix.build.tool }}' == 'cargo' + if: ${{ matrix.build.tool == 'cargo' }} run: rustup target add ${{ matrix.target }} - name: Install cross - if: '${{ matrix.build.tool }}' == 'cross' + if: ${{ matrix.build.tool == 'cross' }} run: cargo install cross --git https://github.com/cross-rs/cross --rev c87a52a - name: Checkout From db67d9a8f21ef1b0ab7a01a2c5fd824681d9e5e8 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 22:51:56 +0200 Subject: [PATCH 06/19] Fix syntax passing env vars to called actions. --- .github/workflows/build-and-publish-bindings.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index b23c51dc9..ef5a15ddf 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -9,15 +9,24 @@ env: RUST_VERSION: 1.78 jobs: + setup: + runs-on: ubuntu-latest + outputs: + rust_version: ${{ env.RUST_VERSION }} + steps: + - run: echo "setting output variables" + generate-bindings: + needs: setup uses: ./.github/workflows/gen-bindings-go.yaml with: - rust_version: ${{ env.RUST_VERSION }} + rust_version: ${{ needs.setup.outputs.rust_version }} build-libraries: + needs: setup uses: ./.github/workflows/build-libraries.yaml with: - rust_version: ${{ env.RUST_VERSION }} + rust_version: ${{ needs.setup.outputs.rust_version }} publish-ldk-node-go: needs: From 71db948da4d009220d3404eee18287424750d391 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Tue, 11 Jun 2024 22:56:48 +0200 Subject: [PATCH 07/19] Require ldk-node deploy key secret in the publish workflow. --- .github/workflows/publish-bindings-go.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index 51cce6e31..3c0c0493b 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -2,6 +2,9 @@ name: Build libraries for all targets on: workflow_call: + secrets: + LDK_NODE_GO_DEPLOY_KEY: + required: true env: LDK_BRANCH_NAME: ${{ github.head_ref || github.ref_name }} From 717b2677371d343ff1f15d5158bacae87dbb2142 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Wed, 12 Jun 2024 14:59:38 +0200 Subject: [PATCH 08/19] Fix GH target var. --- .github/workflows/build-libraries.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-libraries.yaml b/.github/workflows/build-libraries.yaml index 377ed83b9..3d1228d90 100644 --- a/.github/workflows/build-libraries.yaml +++ b/.github/workflows/build-libraries.yaml @@ -27,7 +27,7 @@ jobs: - name: Add target if: ${{ matrix.build.tool == 'cargo' }} - run: rustup target add ${{ matrix.target }} + run: rustup target add ${{ matrix.build.target }} - name: Install cross if: ${{ matrix.build.tool == 'cross' }} From 42757c52bdb826c6bb1ada98df6f4afaabd133f0 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Wed, 12 Jun 2024 15:15:06 +0200 Subject: [PATCH 09/19] Fix paths when downloading Apple lib artifacts. --- .github/workflows/build-libraries.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-libraries.yaml b/.github/workflows/build-libraries.yaml index 3d1228d90..96ca6b525 100644 --- a/.github/workflows/build-libraries.yaml +++ b/.github/workflows/build-libraries.yaml @@ -49,20 +49,17 @@ jobs: runs-on: macos-12 needs: build steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Download macOS artifacts uses: actions/download-artifact@v4 with: name: ldk-node-x86_64-apple-darwin - path: x86_64-apple-darwin/libldk_node.dylib + path: x86_64-apple-darwin - name: Download macOS artifacts uses: actions/download-artifact@v4 with: name: ldk-node-aarch64-apple-darwin - path: aarch64-apple-darwin/libldk_node.dylib + path: aarch64-apple-darwin - name: Make universal library run: | From 61a8f643c560f1fdd5f3b39ff8af7b1f3f606dd2 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Wed, 12 Jun 2024 15:24:36 +0200 Subject: [PATCH 10/19] Remove windows-gnu library from the publish action. --- .github/workflows/publish-bindings-go.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index 3c0c0493b..9a3ae0b9d 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -39,12 +39,6 @@ jobs: name: ldk-node-arm-unknown-linux-gnueabihf path: ldk_node/arm-unknown-linux-gnueabihf - - name: Download Windows x86_64 GNU libs - uses: actions/download-artifact@v4 - with: - name: ldk-node-x86_64-pc-windows-gnu - path: ldk_node/x86_64-pc-windows-gnu - - name: Download Windows x86_64 MSVC libs uses: actions/download-artifact@v4 with: @@ -69,7 +63,6 @@ jobs: git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so - git add ldk_node/x86_64-pc-windows-gnu/ldk_node.dll git add ldk_node/x86_64-pc-windows-msvc/ldk_node.dll git add ldk_node/universal-macos/libldk_node.dylib git commit -m "Update bindings." From e1eb7476a85aa97c0cc6cfe1301c903e16727334 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Wed, 12 Jun 2024 16:01:01 +0200 Subject: [PATCH 11/19] Check out target branch in ldk-node-go before downloading artifacts. --- .github/workflows/publish-bindings-go.yaml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index 9a3ae0b9d..6654d6840 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -21,6 +21,16 @@ jobs: repository: getAlby/ldk-node-go ssh-key: ${{ secrets.LDK_NODE_GO_DEPLOY_KEY }} + - name: Prepare git + run: | + git config --global user.email "github-actions@github.com" + git config --global user.name "github-actions" + git config --global push.autoSetupRemote true + if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then + git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true + fi + - name: Download bindings uses: actions/download-artifact@v4 with: @@ -53,13 +63,6 @@ jobs: - name: Commit and push bindings run: | - git config --global user.email "github-actions@github.com" - git config --global user.name "github-actions" - git config --global push.autoSetupRemote true - if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - fi - git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so @@ -68,7 +71,7 @@ jobs: git commit -m "Update bindings." if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} else - git push origin master + git push origin master fi From b95425e2619a915c4942ab5aaf27556c5b423972 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 21:27:02 +0200 Subject: [PATCH 12/19] fix: disable concurrent workflow executions on the same branch --- .github/workflows/build-and-publish-bindings.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index ef5a15ddf..65defd386 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -5,6 +5,9 @@ on: workflow_dispatch: +concurrency: + group: ${{ github.head_ref || github.ref }} + env: RUST_VERSION: 1.78 From 2652201d84d0eed46ba6fd6559d456e24a71feb6 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 21:27:44 +0200 Subject: [PATCH 13/19] fix: testing concurrency limit --- .github/workflows/build-and-publish-bindings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index 65defd386..908258527 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -5,6 +5,7 @@ on: workflow_dispatch: +# Dummy comment to commit and test concurrency. concurrency: group: ${{ github.head_ref || github.ref }} From ae54eb6d677df787a03c7bef5d6878986bd0b8fc Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 21:28:41 +0200 Subject: [PATCH 14/19] fix: cancel in-progress workflows --- .github/workflows/build-and-publish-bindings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index 908258527..d5597c284 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -8,6 +8,7 @@ on: # Dummy comment to commit and test concurrency. concurrency: group: ${{ github.head_ref || github.ref }} + cancel-in-progress: true env: RUST_VERSION: 1.78 From ba285db50691960bfdf535344097675b4dd21c59 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 21:32:01 +0200 Subject: [PATCH 15/19] fix: limit cancellation to the current workflow --- .github/workflows/build-and-publish-bindings.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish-bindings.yml b/.github/workflows/build-and-publish-bindings.yml index d5597c284..1dd0ca149 100644 --- a/.github/workflows/build-and-publish-bindings.yml +++ b/.github/workflows/build-and-publish-bindings.yml @@ -5,9 +5,8 @@ on: workflow_dispatch: -# Dummy comment to commit and test concurrency. concurrency: - group: ${{ github.head_ref || github.ref }} + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true env: From 31bf7a61234fae75e2b4c3096295da8fd6aaf4d4 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 22:02:20 +0200 Subject: [PATCH 16/19] fix: fetch before checking out feature branch --- .github/workflows/publish-bindings-go.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index 6654d6840..a8ef40682 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -27,6 +27,7 @@ jobs: git config --global user.name "github-actions" git config --global push.autoSetupRemote true if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then + git fetch git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true fi @@ -71,7 +72,7 @@ jobs: git commit -m "Update bindings." if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} else - git push origin master + git push origin master fi From 958f9f9fae324b0b93597aeea5e092b13dc38517 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 22:16:43 +0200 Subject: [PATCH 17/19] fix: remove target branch pull --- .github/workflows/publish-bindings-go.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index a8ef40682..29c1d3e05 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -29,7 +29,6 @@ jobs: if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then git fetch git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true fi - name: Download bindings From 6d5dc37bb6a9717a116d54ea61518494f96a4581 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Fri, 14 Jun 2024 22:34:49 +0200 Subject: [PATCH 18/19] fix: reinstate pull and do ff only --- .github/workflows/publish-bindings-go.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index 29c1d3e05..d2bc82f5b 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -26,9 +26,11 @@ jobs: git config --global user.email "github-actions@github.com" git config --global user.name "github-actions" git config --global push.autoSetupRemote true + git config --global pull.ff only if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then git fetch git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} + git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true fi - name: Download bindings From 017771304bafdc3989af79311365b2d957f9ae41 Mon Sep 17 00:00:00 2001 From: Roman Dmitrienko Date: Sun, 16 Jun 2024 15:03:46 +0200 Subject: [PATCH 19/19] fix: pass branch name to the checkout action --- .github/workflows/publish-bindings-go.yaml | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish-bindings-go.yaml b/.github/workflows/publish-bindings-go.yaml index d2bc82f5b..0e1abb9df 100644 --- a/.github/workflows/publish-bindings-go.yaml +++ b/.github/workflows/publish-bindings-go.yaml @@ -15,23 +15,20 @@ jobs: runs-on: ubuntu-20.04 steps: + - name: Set target branch name + run: | + if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then + echo "TARGET_BRANCH=${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }}" >> $GITHUB_ENV + else + echo "TARGET_BRANCH=master" >> $GITHUB_ENV + fi + - name: Checkout ldk-node-go uses: actions/checkout@v4 with: repository: getAlby/ldk-node-go ssh-key: ${{ secrets.LDK_NODE_GO_DEPLOY_KEY }} - - - name: Prepare git - run: | - git config --global user.email "github-actions@github.com" - git config --global user.name "github-actions" - git config --global push.autoSetupRemote true - git config --global pull.ff only - if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git fetch - git checkout -b ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - git pull origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} || true - fi + ref: ${{ env.TARGET_BRANCH }} - name: Download bindings uses: actions/download-artifact@v4 @@ -65,15 +62,14 @@ jobs: - name: Commit and push bindings run: | + git config --global user.email "github-actions@github.com" + git config --global user.name "github-actions" + git config --global push.autoSetupRemote true + git add ldk_node/ldk_node.go ldk_node/ldk_node.h ldk_node/ldk_node.c git add ldk_node/x86_64-unknown-linux-gnu/libldk_node.so git add ldk_node/arm-unknown-linux-gnueabihf/libldk_node.so git add ldk_node/x86_64-pc-windows-msvc/ldk_node.dll git add ldk_node/universal-macos/libldk_node.dylib git commit -m "Update bindings." - - if [ "${{ env.LDK_BRANCH_NAME }}" != "main" ]; then - git push origin ${{ env.TARGET_BRANCH_PREFIX }}${{ env.LDK_BRANCH_NAME }} - else - git push origin master - fi + git push origin ${{ env.TARGET_BRANCH }}