From f97d2d7d1d669e6369c9e436cba7fc098c005e3d Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 10 Mar 2025 17:33:34 +0800 Subject: [PATCH 1/2] ci:create release --- .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 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 00000000..c01b272d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release + +on: + release: + types: [created, published, prereleased] + +jobs: + build: + strategy: + matrix: + include: + - os: macos-latest + llvm: 18 + platform: darwin + arch: arm64 + - os: ubuntu-24.04 + llvm: 18 + platform: linux + arch: amd64 + runs-on: ${{matrix.os}} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" + + - name: Install dependencies + if: startsWith(matrix.os, 'macos') + run: | + brew update + brew install llvm@${{matrix.llvm}} bdw-gc openssl libffi libuv + brew link --force libffi + echo "$(brew --prefix llvm@${{matrix.llvm}})/bin" >> $GITHUB_PATH + # llcppg dependencies + brew install cjson + - name: Install dependencies + if: startsWith(matrix.os, 'ubuntu') + run: | + echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{matrix.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-get update + sudo apt-get install -y llvm-${{matrix.llvm}}-dev clang-${{matrix.llvm}} libunwind-dev libclang-${{matrix.llvm}}-dev lld-${{matrix.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libcjson-dev libuv1-dev + echo "/usr/lib/llvm-${{matrix.llvm}}/bin" >> $GITHUB_PATH + - name: Install LLGO + run: | + git clone https://github.com/goplus/llgo.git + cd llgo/compiler + go install -v ./cmd/... + export LLGO_ROOT=$GITHUB_WORKSPACE/llgo + echo "LLGO_ROOT=$LLGO_ROOT" >> $GITHUB_ENV + - name: Build components + run: | + mkdir -p build/${{matrix.platform}}-${{matrix.arch}} + cd $GITHUB_WORKSPACE + llgo build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppsymg ./_xtool/llcppsymg + llgo build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppsigfetch ./_xtool/llcppsigfetch + go build -o build/${{matrix.platform}}-${{matrix.arch}}/gogensig ./cmd/gogensig + go build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppg . + go build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppcfg ./cmd/llcppcfg + cd build + zip -r llcppg-${{matrix.platform}}-${{matrix.arch}}.zip ${{matrix.platform}}-${{matrix.arch}}/ + - name: Upload binaries + uses: actions/upload-artifact@v4 + with: + name: llcppg-${{matrix.platform}}-${{matrix.arch}} + path: build/llcppg-${{matrix.platform}}-${{matrix.arch}}.zip + + publish: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download darwin arm64 artifact + uses: actions/download-artifact@v4 + with: + name: llcppg-darwin-arm64 + path: ./artifacts + + - name: Download linux amd64 artifact + uses: actions/download-artifact@v4 + with: + name: llcppg-linux-amd64 + path: ./artifacts + + - name: List artifacts + run: ls -la ./artifacts + + - name: Upload to Release + uses: softprops/action-gh-release@v2 + with: + files: | + ./artifacts/llcppg-darwin-arm64.zip + ./artifacts/llcppg-linux-amd64.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 75bb3e733e13129f2dfad3ca32fee6a9c870fa2f Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Mon, 10 Mar 2025 21:21:33 +0800 Subject: [PATCH 2/2] ci:before release test binaries --- .github/workflows/go.yml | 28 +++------------------------- .github/workflows/release.yml | 27 +++++++++++++++++++++------ .github/workflows/test_linux.sh | 12 ++++++++++++ .github/workflows/test_macos.sh | 13 +++++++++++++ 4 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/test_linux.sh create mode 100644 .github/workflows/test_macos.sh diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d7bc0705..f06e66df 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -119,31 +119,9 @@ jobs: - name: Test demos with generated pkgs if: startsWith(matrix.os, 'macos') - run: | - # install demo's lib - brew install lua zlib isl libgpg-error raylib z3 sqlite3 gmp libxml2 libxslt - - export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig" - export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH="/opt/homebrew/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH" - export PKG_CONFIG_PATH="/opt/homebrew/opt/libxslt/lib/pkgconfig:$PKG_CONFIG_PATH" - pkg-config --cflags --libs sqlite3 - pkg-config --cflags --libs libxslt - - llcppgtest -demos ./_llcppgtest + run: bash .github/workflows/test_macos.sh + - name: Test demos with generated pkgs if: startsWith(matrix.os, 'ubuntu') - run: | - # install demo's lib - sudo apt install liblua5.4-dev libsqlite3-dev libgmp-dev libgpg-error-dev zlib1g-dev libisl-dev libz3-dev -y - llcppgtest -demo ./_llcppgtest/cjson -conf conf/linux - llcppgtest -demo ./_llcppgtest/gmp -conf conf/linux - llcppgtest -demo ./_llcppgtest/gpgerror -conf conf/linux - llcppgtest -demo ./_llcppgtest/isl - llcppgtest -demo ./_llcppgtest/lua -conf conf/linux - llcppgtest -demo ./_llcppgtest/sqlite -conf conf/linux - llcppgtest -demo ./_llcppgtest/z3 -conf conf/linux - llcppgtest -demo ./_llcppgtest/zlib -conf conf/linux - - + run: bash .github/workflows/test_linux.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c01b272d..de3a2b05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,15 +53,30 @@ jobs: echo "LLGO_ROOT=$LLGO_ROOT" >> $GITHUB_ENV - name: Build components run: | - mkdir -p build/${{matrix.platform}}-${{matrix.arch}} + BINDIR="$GITHUB_WORKSPACE/build/${{matrix.platform}}-${{matrix.arch}}" + mkdir -p $BINDIR cd $GITHUB_WORKSPACE - llgo build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppsymg ./_xtool/llcppsymg - llgo build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppsigfetch ./_xtool/llcppsigfetch - go build -o build/${{matrix.platform}}-${{matrix.arch}}/gogensig ./cmd/gogensig - go build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppg . - go build -o build/${{matrix.platform}}-${{matrix.arch}}/llcppcfg ./cmd/llcppcfg + llgo build -o $BINDIR/llcppsymg ./_xtool/llcppsymg + llgo build -o $BINDIR/llcppsigfetch ./_xtool/llcppsigfetch + go build -o $BINDIR/gogensig ./cmd/gogensig + go build -o $BINDIR/llcppg . + go build -o $BINDIR/llcppcfg ./cmd/llcppcfg cd build zip -r llcppg-${{matrix.platform}}-${{matrix.arch}}.zip ${{matrix.platform}}-${{matrix.arch}}/ + + - name: Prepare llcppg binaries test + run: | + go install ./cmd/llcppgtest + echo "PATH=$GITHUB_WORKSPACE/build/${{matrix.platform}}-${{matrix.arch}}:$PATH" >> $GITHUB_ENV + + - name: Test llcppg binaries with demo test + if: startsWith(matrix.os, 'macos') + run: bash .github/workflows/test_macos.sh + + - name: Test llcppg binaries with demo test + if: startsWith(matrix.os, 'ubuntu') + run: bash .github/workflows/test_linux.sh + - name: Upload binaries uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/test_linux.sh b/.github/workflows/test_linux.sh new file mode 100644 index 00000000..7652235b --- /dev/null +++ b/.github/workflows/test_linux.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +sudo apt install liblua5.4-dev libsqlite3-dev libgmp-dev libgpg-error-dev zlib1g-dev libisl-dev libz3-dev -y +llcppgtest -demo ./_llcppgtest/cjson -conf conf/linux +llcppgtest -demo ./_llcppgtest/gmp -conf conf/linux +llcppgtest -demo ./_llcppgtest/gpgerror -conf conf/linux +llcppgtest -demo ./_llcppgtest/isl +llcppgtest -demo ./_llcppgtest/lua -conf conf/linux +llcppgtest -demo ./_llcppgtest/sqlite -conf conf/linux +llcppgtest -demo ./_llcppgtest/z3 -conf conf/linux +llcppgtest -demo ./_llcppgtest/zlib -conf conf/linux diff --git a/.github/workflows/test_macos.sh b/.github/workflows/test_macos.sh new file mode 100644 index 00000000..9f960c75 --- /dev/null +++ b/.github/workflows/test_macos.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +brew install lua zlib isl libgpg-error raylib z3 sqlite3 gmp libxml2 libxslt + +export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig" +export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig:$PKG_CONFIG_PATH" +export PKG_CONFIG_PATH="/opt/homebrew/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH" +export PKG_CONFIG_PATH="/opt/homebrew/opt/libxslt/lib/pkgconfig:$PKG_CONFIG_PATH" +pkg-config --cflags --libs sqlite3 +pkg-config --cflags --libs libxslt + +llcppgtest -demos ./_llcppgtest \ No newline at end of file