From caa33b640058d0adb9376e3771e1e7566b0da364 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 15:29:43 +0800 Subject: [PATCH 1/8] update workflow --- .github/workflows/release.yml | 69 +++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55b87c3..93345d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,29 +3,36 @@ name: Release on: release: types: [published] - + workflow_dispatch: inputs: tag: - description: 'Tag to build (optional)' + description: "Tag to build (optional)" required: false - default: '' + default: "" -permissions: read-all +permissions: + contents: write jobs: build: name: Build ${{ matrix.platform }} strategy: matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest + include: + - os: ubuntu-latest + platform: linux-x86_64 + binary_name: agent-sync-linux-x86_64 + - os: macos-latest + platform: darwin-arm64 + binary_name: agent-sync-darwin-arm64 + - os: windows-latest + platform: windows-x86_64 + binary_name: agent-sync-windows-x86_64.exe fail-fast: false - - runs-on: ${{ matrix.platform }} - + + runs-on: ${{ matrix.os }} + steps: - name: Checkout tree uses: actions/checkout@v4 @@ -35,9 +42,41 @@ jobs: with: ocaml-compiler: 5 - - run: opam install . --deps-only --with-test + - name: Install dependencies + run: opam install . --deps-only --with-test + + - name: Build + run: opam exec -- dune build - - run: opam exec -- dune build + - name: Run tests + run: opam exec -- dune runtest - - run: opam exec -- dune runtest - + - name: Install + run: opam install . --destdir _install + + - name: Package binary (Unix) + if: matrix.os != 'windows-latest' + run: | + mkdir -p release + cp _install/usr/local/bin/agent-sync release/${{ matrix.binary_name }} + chmod +x release/${{ matrix.binary_name }} + tar -czf agent-sync-${{ matrix.platform }}.tar.gz -C release ${{ matrix.binary_name }} + sha256sum agent-sync-${{ matrix.platform }}.tar.gz > agent-sync-${{ matrix.platform }}.tar.gz.sha256 + + - name: Package binary (Windows) + if: matrix.os == 'windows-latest' + run: | + mkdir -p release + copy _install\usr\local\bin\agent-sync.exe\release\${{ matrix.binary_name }} + 7z a agent-sync-${{ matrix.platform }}.zip release\${{ matrix.binary_name }} + sha256sum agent-sync-${{ matrix.platform }}.zip > agent-sync-${{ matrix.platform }}.zip.sha256 + + - name: Upload Release Asset + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + ./agent-sync-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} + ./agent-sync-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0b38b55c804c8db5bc2bbcfd2e379b168af9b6fa Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 15:40:19 +0800 Subject: [PATCH 2/8] update workflow --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93345d2..058b3c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,7 +58,7 @@ jobs: if: matrix.os != 'windows-latest' run: | mkdir -p release - cp _install/usr/local/bin/agent-sync release/${{ matrix.binary_name }} + cp _install/bin/agent-sync release/${{ matrix.binary_name }} chmod +x release/${{ matrix.binary_name }} tar -czf agent-sync-${{ matrix.platform }}.tar.gz -C release ${{ matrix.binary_name }} sha256sum agent-sync-${{ matrix.platform }}.tar.gz > agent-sync-${{ matrix.platform }}.tar.gz.sha256 @@ -67,7 +67,7 @@ jobs: if: matrix.os == 'windows-latest' run: | mkdir -p release - copy _install\usr\local\bin\agent-sync.exe\release\${{ matrix.binary_name }} + copy _install\bin\agent-sync.exe\release\${{ matrix.binary_name }} 7z a agent-sync-${{ matrix.platform }}.zip release\${{ matrix.binary_name }} sha256sum agent-sync-${{ matrix.platform }}.zip > agent-sync-${{ matrix.platform }}.zip.sha256 From 093d404f8971be659575b815030e0bbc4a706c31 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 15:45:36 +0800 Subject: [PATCH 3/8] Update workflow --- .github/workflows/release.yml | 41 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 058b3c1..afebe82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,13 +22,13 @@ jobs: include: - os: ubuntu-latest platform: linux-x86_64 - binary_name: agent-sync-linux-x86_64 + binary_ext: "" - os: macos-latest platform: darwin-arm64 - binary_name: agent-sync-darwin-arm64 + binary_ext: "" - os: windows-latest platform: windows-x86_64 - binary_name: agent-sync-windows-x86_64.exe + binary_ext: ".exe" fail-fast: false runs-on: ${{ matrix.os }} @@ -37,6 +37,21 @@ jobs: - name: Checkout tree uses: actions/checkout@v4 + - name: Extract version from tag + id: version + run: | + if [[ "${{ github.event_name }}" == "release" ]]; then + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + if [[ -n "${{ github.event.inputs.tag }}" ]]; then + echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "VERSION=dev-${{ github.sha }}" >> $GITHUB_OUTPUT + fi + else + echo "VERSION=dev-${{ github.sha }}" >> $GITHUB_OUTPUT + fi + - name: Set-up OCaml uses: ocaml/setup-ocaml@v3 with: @@ -58,25 +73,25 @@ jobs: if: matrix.os != 'windows-latest' run: | mkdir -p release - cp _install/bin/agent-sync release/${{ matrix.binary_name }} - chmod +x release/${{ matrix.binary_name }} - tar -czf agent-sync-${{ matrix.platform }}.tar.gz -C release ${{ matrix.binary_name }} - sha256sum agent-sync-${{ matrix.platform }}.tar.gz > agent-sync-${{ matrix.platform }}.tar.gz.sha256 + cp _install/bin/agent-sync release/agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + chmod +x release/agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + tar -czf agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz -C release agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz.sha256 - name: Package binary (Windows) if: matrix.os == 'windows-latest' run: | mkdir -p release - copy _install\bin\agent-sync.exe\release\${{ matrix.binary_name }} - 7z a agent-sync-${{ matrix.platform }}.zip release\${{ matrix.binary_name }} - sha256sum agent-sync-${{ matrix.platform }}.zip > agent-sync-${{ matrix.platform }}.zip.sha256 + copy _install\bin\agent-sync.exe release\agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + 7z a agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip release\agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip.sha256 - name: Upload Release Asset uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' with: files: | - ./agent-sync-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} - ./agent-sync-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7d0f3ab0d91d0005f909cd7fe434ad4b802d46a8 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 15:50:35 +0800 Subject: [PATCH 4/8] Update workflow --- .github/workflows/release.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afebe82..4c60cf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,10 +88,19 @@ jobs: - name: Upload Release Asset uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' + if: startsWith(github.ref, 'refs/tags/') with: files: | ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Artifacts (Manual Build) + uses: actions/upload-artifact@v4 + if: github.event_name == 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/') + with: + name: agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }} + path: | + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 From 83b280b0a372ca2335385ae5f32559fdad02fff9 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 15:55:42 +0800 Subject: [PATCH 5/8] Update workflow --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c60cf4..446c747 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,6 +39,7 @@ jobs: - name: Extract version from tag id: version + shell: bash run: | if [[ "${{ github.event_name }}" == "release" ]]; then echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT From 58f78bb61e3d28a28133c53eb20bdd0c70e1d786 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 16:00:28 +0800 Subject: [PATCH 6/8] Update workflow --- .github/workflows/release.yml | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 446c747..3c2bffe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,30 +70,23 @@ jobs: - name: Install run: opam install . --destdir _install - - name: Package binary (Unix) - if: matrix.os != 'windows-latest' + - name: Prepare binary run: | - mkdir -p release - cp _install/bin/agent-sync release/agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} - chmod +x release/agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} - tar -czf agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz -C release agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} - sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.tar.gz.sha256 - - - name: Package binary (Windows) - if: matrix.os == 'windows-latest' - run: | - mkdir -p release - copy _install\bin\agent-sync.exe release\agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} - 7z a agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip release\agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} - sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip.sha256 + if [ "${{ matrix.os }}" == "windows-latest" ]; then + cp _install\bin\agent-sync.exe agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + else + cp _install/bin/agent-sync agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + chmod +x agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + fi + sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256 - name: Upload Release Asset uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: files: | - ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} - ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -103,5 +96,5 @@ jobs: with: name: agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }} path: | - ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }} - ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.${{ matrix.os == 'windows-latest' && 'zip' || 'tar.gz' }}.sha256 + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + ./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256 From 44dde4e03fd49891aa5f0ccad2e4689b5f1733b0 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 16:17:33 +0800 Subject: [PATCH 7/8] Update workflow --- .github/workflows/release.yml | 1 + .gitignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c2bffe..b6926c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -71,6 +71,7 @@ jobs: run: opam install . --destdir _install - name: Prepare binary + shell: bash run: | if [ "${{ matrix.os }}" == "windows-latest" ]; then cp _install\bin\agent-sync.exe agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} diff --git a/.gitignore b/.gitignore index 006f7ba..e6a9fed 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ # ocamlbuild and Dune default working directory _build/ +_install/ # ocamlbuild targets *.byte From 0ca5be45fe65c38335d28211a531c072b3092ec5 Mon Sep 17 00:00:00 2001 From: Haoyuan Li <1513624626@qq.com> Date: Wed, 20 Aug 2025 16:27:33 +0800 Subject: [PATCH 8/8] Update workflow --- .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 b6926c4..b089b31 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,7 @@ jobs: shell: bash run: | if [ "${{ matrix.os }}" == "windows-latest" ]; then - cp _install\bin\agent-sync.exe agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} + cp _install/bin/agent-sync.exe agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} else cp _install/bin/agent-sync agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} chmod +x agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}