From 30e55c7322bcc408fcb1ff43c608967160f7f474 Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:04:38 +0900 Subject: [PATCH 1/9] add release automation workflow for binary distribution --- .github/workflows/release.yml | 138 ++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..03f1320 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,138 @@ +name: Release + +on: + push: + branches: + - main + tags: ['*'] + +jobs: + build: + runs-on: ubuntu-22.04 + strategy: + fail-fast: true + matrix: + target: + - x86_64-unknown-linux-musl + + steps: + - uses: actions/checkout@v4.1.1 + + - name: install apt depenedencies + run: | + sudo apt-get update + sudo apt-get install -y musl-tools + + - name: Get Rust toolchain + id: toolchain + working-directory: . + run: | + awk -F'[ ="]+' '$1 == "channel" { print "toolchain=" $2 }' rust-toolchain >> "$GITHUB_OUTPUT" + + - uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ steps.toolchain.outputs.toolchain }} + targets: ${{ matrix.target }} + + - uses: Swatinem/rust-cache@v2.7.3 + + - name: install cargo-about + run: | + cargo install --locked cargo-about + + - name: Build + run: | + cargo build --target=${{ matrix.target }} --release --locked + + - name: Rename binaries + run: | + mkdir bin + kble_bins=("kble" "kble-c2a" "kble-eb90" "kble-serialport") + for b in "${kble_bins[@]}" ; do + cp "./target/${{ matrix.target }}/release/${b}" "./bin/${b}-${{ matrix.target }}" + done + ls -lh ./bin + + - uses: actions/upload-artifact@v4.3.1 + with: + name: release-executable-${{ matrix.target }} + if-no-files-found: error + path: ./bin/ + + build_kble_serialport_win: + name: build / kble-serialport.exe + # C2A Boom ecosystem does **NOT** support native Windows environment. + # However, WSL2 environment is supported and has many use cases in the real world. + # Here, there are difficulties in running kble-serialport inside WSL2, + # a component that interfaces with external hardware (USB-RS devices). + # Although it is possible to show a Windows host USB devices + # to a WSL2 Linux VM using the usbipd-win project, this is still a bit unstable. + # Also, kble-serialport is a very small component that does not need to be updated frequently for practical use. + # For these reasons, we currently choose to run only kble-serialport on Windows host. + + runs-on: windows-2022 + + env: + TARGET: x86_64-pc-windows-msvc + + steps: + - uses: actions/checkout@v4.1.1 + + - name: Get Rust toolchain + id: toolchain + working-directory: . + run: | + awk -F'[ ="]+' '$1 == "channel" { print "toolchain=" $2 }' rust-toolchain >> "$GITHUB_OUTPUT" + + - uses: dtolnay/rust-toolchain@v1 + with: + toolchain: ${{ steps.toolchain.outputs.toolchain }} + targets: ${{ env.TARGET }} + + - uses: Swatinem/rust-cache@v2.7.3 + + - name: install cargo-about + run: | + cargo install --locked cargo-about + + - name: Build + run: | + cargo build --target=${{ env.TARGET }} -p kble-serialport --release --locked + + - name: Rename binary + run: | + mkdir bin + cp "./target/${{ env.TARGET }}/release/kble-serialport" "./bin/kble-serialport-${{ env.TARGET }}" + ls -lh ./bin + + - uses: actions/upload-artifact@v4.3.1 + with: + name: release-executable-${{ env.TARGET }} + if-no-files-found: error + path: ./bin/ + + release: + name: Release + needs: [ build, build_kble_serialport_win ] + permissions: + contents: write + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/download-artifact@v4.1.3 + with: + pattern: release-executable-* + merge-multiple: true + + - run: ls -lh + + - name: Release to GitHub Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v0.1.15 + with: + draft: true + fail_on_unmatched_files: true + generate_release_notes: true + files: | + kble* From d193d704003162b2cf819304ed62d21b344e5c8d Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:19:25 +0900 Subject: [PATCH 2/9] dry-run release workflow --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03f1320..4aa9a4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - add-release-workflow tags: ['*'] jobs: From fdfccb031170e43287cfe3b542a0c3bc0bf75c96 Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:25:17 +0900 Subject: [PATCH 3/9] specify bash excplicitly to use real awk command in get Rust toolchain step on Windows runner --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4aa9a4d..c13610e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: - name: Get Rust toolchain id: toolchain working-directory: . + shell: bash run: | awk -F'[ ="]+' '$1 == "channel" { print "toolchain=" $2 }' rust-toolchain >> "$GITHUB_OUTPUT" From 2b502c7120869a65953a18d5d3e280f8e432c4cc Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:32:12 +0900 Subject: [PATCH 4/9] fix add .exe suffix --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c13610e..01f912e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -104,7 +104,7 @@ jobs: - name: Rename binary run: | mkdir bin - cp "./target/${{ env.TARGET }}/release/kble-serialport" "./bin/kble-serialport-${{ env.TARGET }}" + cp "./target/${{ env.TARGET }}/release/kble-serialport.exe" "./bin/kble-serialport-${{ env.TARGET }}.exe" ls -lh ./bin - uses: actions/upload-artifact@v4.3.1 From 4987ea784def292308c6103919458bcb05504f94 Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:39:14 +0900 Subject: [PATCH 5/9] specify bash excplicitly to use real cp, ls command --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01f912e..75362d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,6 +102,7 @@ jobs: cargo build --target=${{ env.TARGET }} -p kble-serialport --release --locked - name: Rename binary + shell: bash run: | mkdir bin cp "./target/${{ env.TARGET }}/release/kble-serialport.exe" "./bin/kble-serialport-${{ env.TARGET }}.exe" From 1ac3ec250e81f57bff7e2f8fe1a5403456fd04ce Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:49:14 +0900 Subject: [PATCH 6/9] make binary executable --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75362d7..b3d4a0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -128,6 +128,8 @@ jobs: pattern: release-executable-* merge-multiple: true + - run: chmod +x kble-* + - run: ls -lh - name: Release to GitHub Release From 6cb91c55ea36f37044d97655583575c538660eae Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:56:25 +0900 Subject: [PATCH 7/9] bump version to 0.3.0-beta.1 to test release workflow --- Cargo.lock | 29 ++++++++++++++++++++++------- Cargo.toml | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2be6f5a..60a49d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -776,7 +776,7 @@ dependencies = [ [[package]] name = "kble" -version = "0.2.0" +version = "0.3.0-beta.1" dependencies = [ "anyhow", "async-trait", @@ -796,13 +796,13 @@ dependencies = [ [[package]] name = "kble-c2a" -version = "0.2.0" +version = "0.3.0-beta.1" dependencies = [ "anyhow", "bytes", "clap", "futures", - "kble-socket", + "kble-socket 0.2.0", "notalawyer", "notalawyer-build", "notalawyer-clap", @@ -814,14 +814,14 @@ dependencies = [ [[package]] name = "kble-eb90" -version = "0.2.0" +version = "0.3.0-beta.1" dependencies = [ "anyhow", "bytes", "clap", "eb90", "futures", - "kble-socket", + "kble-socket 0.2.0", "notalawyer", "notalawyer-build", "notalawyer-clap", @@ -833,14 +833,14 @@ dependencies = [ [[package]] name = "kble-serialport" -version = "0.2.0" +version = "0.3.0-beta.1" dependencies = [ "anyhow", "axum", "bytes", "clap", "futures", - "kble-socket", + "kble-socket 0.2.0", "notalawyer", "notalawyer-build", "notalawyer-clap", @@ -854,6 +854,21 @@ dependencies = [ [[package]] name = "kble-socket" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9610dc8c2368c5ead741d084e97872a902107f3566bf852506e2fa7a67186aaa" +dependencies = [ + "anyhow", + "axum", + "bytes", + "futures-util", + "pin-project-lite", + "tokio", + "tokio-tungstenite", +] + +[[package]] +name = "kble-socket" +version = "0.3.0-beta.1" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 7ab01c2..9e5077a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.2.0" +version = "0.3.0-beta.1" repository = "https://github.com/arkedge/kble" license = "MIT" edition = "2021" From 2eb2f53d729e254b39bbcd6aee668eb1b9cb36f9 Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 16:59:10 +0900 Subject: [PATCH 8/9] restrict release on version tag --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3d4a0e..830f585 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: branches: - main - add-release-workflow - tags: ['*'] + tags: ['v*'] jobs: build: From 44c560d926e256c1cc4fad809ba9c1c9ffe6a605 Mon Sep 17 00:00:00 2001 From: sksat Date: Wed, 28 Feb 2024 17:01:22 +0900 Subject: [PATCH 9/9] Revert "dry-run release workflow" This reverts commit d193d704003162b2cf819304ed62d21b344e5c8d. --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 830f585..1c5c240 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - add-release-workflow tags: ['v*'] jobs: