From eae94301997641f01b8f4ec2dcc922469e5bac8f Mon Sep 17 00:00:00 2001 From: peefy Date: Sun, 20 Oct 2024 19:16:44 +0800 Subject: [PATCH] chore: update release os and arch info Signed-off-by: peefy --- .../workflows/build-test-centos7-amd64.yaml | 12 ++++++-- .github/workflows/build-test-macos-arm64.yml | 16 +++++++---- .github/workflows/build-test-ubuntu-arm64.yml | 12 ++++++-- .github/workflows/macos_test.yaml | 20 ++++++++----- .github/workflows/mingw_test.yaml | 8 +++++- .github/workflows/ubuntu_test.yaml | 18 ++++-------- .github/workflows/windows_test.yaml | 15 ++++++++-- .gitignore | 2 +- Makefile | 4 +-- run.sh | 21 +++++++++----- scripts/build-windows/build.ps1 | 5 ---- scripts/build.sh | 28 +++++++++---------- scripts/release.sh | 27 +++++++++++++----- 13 files changed, 118 insertions(+), 70 deletions(-) diff --git a/.github/workflows/build-test-centos7-amd64.yaml b/.github/workflows/build-test-centos7-amd64.yaml index d5b1a48d1..d5eaadbad 100644 --- a/.github/workflows/build-test-centos7-amd64.yaml +++ b/.github/workflows/build-test-centos7-amd64.yaml @@ -37,11 +37,17 @@ jobs: /bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && git add . && git commit -m 'chore: bump llvm version to 7.0' && make && make release" - name: Show Artifact Version - run: _build/dist/centos/kclvm/bin/kclvm_cli version + run: _build/dist/linux/kclvm/bin/kclvm_cli version + + - name: Read VERSION file + id: read_version + run: | + VERSION=$(cat VERSION) + echo "VERSION=v${VERSION}" >> $GITHUB_ENV - name: Upload Artifact uses: actions/upload-artifact@v4 with: - name: kcl-centos7-amd64 + name: kcl-${{ env.VERSION }}-linux-amd64 if-no-files-found: error - path: _build/kclvm-centos-latest.tar.gz + path: _build/kclvm-${{ env.VERSION }}-linux-amd64.tar.gz diff --git a/.github/workflows/build-test-macos-arm64.yml b/.github/workflows/build-test-macos-arm64.yml index c51fff0ba..fc5b770ee 100644 --- a/.github/workflows/build-test-macos-arm64.yml +++ b/.github/workflows/build-test-macos-arm64.yml @@ -41,20 +41,26 @@ jobs: python-version: '3.11' - name: Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make && make test-grammar + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make && make test-grammar shell: bash - name: Evaluator Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make test-grammar-evaluator + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make test-grammar-evaluator shell: bash - name: Release - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make release + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make release shell: bash + - name: Read VERSION file + id: read_version + run: | + VERSION=$(cat VERSION) + echo "VERSION=v${VERSION}" >> $GITHUB_ENV + - uses: actions/upload-artifact@v4 if: "contains(matrix.os, 'macos-13-xlarge')" with: - name: kcl-darwin-arm64 + name: kcl-${{ env.VERSION }}-darwin-arm64 if-no-files-found: error - path: _build/kclvm-Darwin-latest.tar.gz + path: _build/kclvm-${{ env.VERSION }}-darwin-arm64.tar.gz diff --git a/.github/workflows/build-test-ubuntu-arm64.yml b/.github/workflows/build-test-ubuntu-arm64.yml index 89dec5af8..b084c711a 100644 --- a/.github/workflows/build-test-ubuntu-arm64.yml +++ b/.github/workflows/build-test-ubuntu-arm64.yml @@ -33,11 +33,17 @@ jobs: docker run --rm --platform linux/arm64 \ -v ${{ github.workspace }}:/workspace -w /workspace \ kcllang/kcl-builder-arm64 \ - /bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && make && make release && _build/dist/ubuntu/kclvm/bin/kclvm_cli version" + /bin/bash -c "export KCL_BUILD_GIT_SHA=$(git rev-parse HEAD) && git config --global --add safe.directory /workspace && git config --global user.name 'GitHub Action' && git config --global user.email 'action@github.com' && make && make release && _build/dist/linux/kclvm/bin/kclvm_cli version" + + - name: Read VERSION file + id: read_version + run: | + VERSION=$(cat VERSION) + echo "VERSION=v${VERSION}" >> $GITHUB_ENV - name: Upload Artifact uses: actions/upload-artifact@v4 with: - name: kcl-linux-arm64 + name: kcl-${{ env.VERSION }}-linux-arm64 if-no-files-found: error - path: _build/kclvm-ubuntu-latest.tar.gz + path: _build/kclvm-${{ env.VERSION }}-linux-arm64.tar.gz diff --git a/.github/workflows/macos_test.yaml b/.github/workflows/macos_test.yaml index 768dc0562..1fc23714f 100644 --- a/.github/workflows/macos_test.yaml +++ b/.github/workflows/macos_test.yaml @@ -56,20 +56,20 @@ jobs: shell: bash - name: Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make && make test-grammar + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make && make test-grammar shell: bash - name: Evaluator Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make test-grammar-evaluator + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make test-grammar-evaluator shell: bash - name: Runtime test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make test-runtime + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make test-runtime shell: bash - name: Unit test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make codecov-lcov + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make codecov-lcov shell: bash - name: Coveralls upload @@ -79,12 +79,18 @@ jobs: path-to-lcov: ./kclvm/.kclvm_cov/lcov.info - name: Release - run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin && make release + run: export PATH=$PATH:$PWD/../_build/dist/darwin/kclvm/bin && make release shell: bash + - name: Read VERSION file + id: read_version + run: | + VERSION=$(cat VERSION) + echo "VERSION=v${VERSION}" >> $GITHUB_ENV + - uses: actions/upload-artifact@v4 if: "contains(matrix.os, 'macos-12')" with: - name: kcl-darwin-amd64 + name: kcl-${{ env.VERSION }}-darwin-amd64 if-no-files-found: error - path: _build/kclvm-Darwin-latest.tar.gz + path: _build/kclvm-${{ env.VERSION }}-darwin-amd64.tar.gz diff --git a/.github/workflows/mingw_test.yaml b/.github/workflows/mingw_test.yaml index 5ad74bc4c..9da87ded4 100644 --- a/.github/workflows/mingw_test.yaml +++ b/.github/workflows/mingw_test.yaml @@ -32,9 +32,15 @@ jobs: rustup target add x86_64-pc-windows-gnu cargo build -r --target x86_64-pc-windows-gnu + - name: Read VERSION file + id: read_version + run: | + $version = Get-Content VERSION + echo "VERSION=v$version" >> $env:GITHUB_ENV + - uses: actions/upload-artifact@v4 with: - name: kcl-windows-mingw + name: kcl-${{ env.VERSION }}-windows-mingw if-no-files-found: error path: | kclvm/target/x86_64-pc-windows-gnu/release/libkclvm_cli_cdylib.a diff --git a/.github/workflows/ubuntu_test.yaml b/.github/workflows/ubuntu_test.yaml index 61efd2205..1ca29c7e0 100644 --- a/.github/workflows/ubuntu_test.yaml +++ b/.github/workflows/ubuntu_test.yaml @@ -23,14 +23,12 @@ jobs: # Prerequisite - - name: Install Python3 and LLVM + - name: Install Python3 (for Grammar test) shell: bash run: | sudo apt-get update sudo apt-get install -y git wget curl make sudo apt-get install python3 python3-pip -y - sudo apt-get install -y clang-12 lld-12 - sudo ln -sf /usr/bin/clang-12 /usr/bin/clang - name: Install rust nightly toolchain uses: actions-rs/toolchain@v1 with: @@ -47,15 +45,15 @@ jobs: shell: bash - name: Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/ubuntu/kclvm/bin && make && make test-grammar + run: export PATH=$PATH:$PWD/../_build/dist/linux/kclvm/bin && make && make test-grammar shell: bash - name: Evaluator Grammar test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/ubuntu/kclvm/bin && make test-grammar-evaluator + run: export PATH=$PATH:$PWD/../_build/dist/linux/kclvm/bin && make test-grammar-evaluator shell: bash - name: Runtime test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/ubuntu/kclvm/bin && make test-runtime + run: export PATH=$PATH:$PWD/../_build/dist/linux/kclvm/bin && make test-runtime shell: bash - name: Install KCL CLI run: | @@ -65,11 +63,5 @@ jobs: - name: Unit test working-directory: ./kclvm - run: export PATH=$PATH:$PWD/../_build/dist/ubuntu/kclvm/bin && make test + run: export PATH=$PATH:$PWD/../_build/dist/linux/kclvm/bin && make test shell: bash - - - uses: actions/upload-artifact@v4 - with: - name: kcl-linux-amd64 - if-no-files-found: error - path: _build/dist/ubuntu/kclvm diff --git a/.github/workflows/windows_test.yaml b/.github/workflows/windows_test.yaml index f0ac20701..37ada8537 100644 --- a/.github/workflows/windows_test.yaml +++ b/.github/workflows/windows_test.yaml @@ -64,8 +64,19 @@ jobs: - run: cargo test --workspace -r -- --nocapture working-directory: ./kclvm + - name: Read VERSION file + id: read_version + run: | + $version = Get-Content VERSION + echo "VERSION=v$version" >> $env:GITHUB_ENV + + - name: Rename kclvm-windows folder + run: | + $version = "${{ env.VERSION }}" + Rename-Item -Path ".\scripts\build-windows\_output\kclvm-windows" -NewName "kclvm-$version-windows" + - uses: actions/upload-artifact@v4 with: - name: kcl-windows + name: kcl-${{ env.VERSION }}-windows if-no-files-found: error - path: scripts/build-windows/_output/kclvm-windows + path: scripts/build-windows/_output/kclvm-${{ env.VERSION }}-windows diff --git a/.gitignore b/.gitignore index 85fda6cd9..5af2a7fca 100644 --- a/.gitignore +++ b/.gitignore @@ -76,7 +76,7 @@ lark_parser.pickle /scripts/docker/kclvm-builder-ubuntu/crates.io-index *.tar.gz -# KCLVM cache and temp output +# KCL cache and temp output .kclvm .kclvm_cov *.dylib diff --git a/Makefile b/Makefile index d3f59142e..32541693d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Copyright The KCL Authors. All rights reserved. -PROJECT_NAME = KCLVM +PROJECT_NAME = kcl PWD:=$(shell pwd) @@ -18,7 +18,7 @@ RUN_IN_DOCKER+=-v ${PWD}:/root/kclvm RUN_IN_DOCKER+=-w /root/kclvm ${BUILD_IMAGE} # ---------------- -# KCLVM build +# Build # ---------------- .PHONY: build diff --git a/run.sh b/run.sh index 2c73a4dbd..fae2cc480 100755 --- a/run.sh +++ b/run.sh @@ -1,13 +1,20 @@ #!/usr/bin/env bash # Environment -if [ -f "/etc/os-release" ]; then - source /etc/os-release - os=$ID -else - os=$(uname) -fi +getSystemInfo() { + arch=$(uname -m) + case $arch in + armv7*) arch="arm";; + aarch64) arch="arm64";; + x86_64) arch="amd64";; + esac + + os=$(echo `uname`|tr '[:upper:]' '[:lower:]') +} + +getSystemInfo topdir=$PWD +version=v$(cat VERSION) # Options help_message=$(cat <<-END @@ -63,4 +70,4 @@ if [ "$action" == "" ]; then done fi -os=$os topdir=$topdir sslpath=$sslpath $topdir/scripts/$action.sh +topdir=$topdir version=$version sslpath=$sslpath $topdir/scripts/$action.sh diff --git a/scripts/build-windows/build.ps1 b/scripts/build-windows/build.ps1 index cee106bee..c6f81258a 100644 --- a/scripts/build-windows/build.ps1 +++ b/scripts/build-windows/build.ps1 @@ -10,7 +10,6 @@ Set-Location $PSScriptRoot New-Item -ErrorAction Ignore -Path ".\_output" -ItemType "directory" New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows" -ItemType "directory" New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows\bin" -ItemType "directory" -New-Item -ErrorAction Ignore -Path ".\_output\kclvm-windows\include" -ItemType "directory" Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll" -Destination ".\_output\kclvm-windows\bin\kclvm_cli_cdylib.dll" -Force Copy-Item -Path "..\..\kclvm\target\release\kclvm_cli_cdylib.dll.lib" -Destination ".\_output\kclvm-windows\bin\kclvm_cli_cdylib.lib" -Force @@ -30,10 +29,6 @@ cargo build --release Set-Location $PSScriptRoot Copy-Item -Path "..\..\kclvm\target\release\kcl-language-server.exe" -Destination ".\_output\kclvm-windows\bin\" -Set-Location $PSScriptRoot -# 4. Copy KCLVM C API header -Copy-Item -Path "..\..\kclvm\runtime\src\_kclvm.h" -Destination ".\_output\kclvm-windows\include\kclvm.h" -Force - Set-Location $PSScriptRoot # Install hello.k Copy-Item -Path "..\..\samples\hello.k" -Destination ".\_output\kclvm-windows" -Force diff --git a/scripts/build.sh b/scripts/build.sh index 867d462a3..c9a2dfb88 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,17 +5,22 @@ set -e # Environment -if [ -f "/etc/os-release" ]; then - source /etc/os-release - os=$ID -else - os=$(uname) -fi +getSystemInfo() { + arch=$(uname -m) + case $arch in + armv7*) arch="arm";; + aarch64) arch="arm64";; + x86_64) arch="amd64";; + esac + + os=$(echo `uname`|tr '[:upper:]' '[:lower:]') +} + +getSystemInfo prepare_dirs () { install_dir="$topdir/_build/dist/$os/kclvm" mkdir -p "$install_dir/bin" - mkdir -p "$install_dir/include" } prepare_dirs @@ -32,7 +37,7 @@ cargo build --release ## Switch dll file extension according to os. dll_extension="so" case $os in - "Default" | "default" | "centos" | "ubuntu" | "debian" | "Ubuntu" |"Debian" | "Static-Debian" | "Cood1-Debian" | "Cood1Shared-Debian") + "Linux" | "linux" | "Default" | "default" | "centos" | "ubuntu" | "debian" | "Ubuntu" | "Debian" | "Static-Debian" | "Cood1-Debian" | "Cood1Shared-Debian") dll_extension="so" ;; "Darwin" | "darwin" | "ios" | "macos") @@ -42,11 +47,6 @@ case $os in ;; esac -## Copy C API header - -cd $topdir/kclvm/runtime -cp src/_kclvm.h $install_dir/include/kclvm.h - ## Copy libkclvm_cli lib to the build folder if [ -e $topdir/kclvm/target/release/libkclvm_cli_cdylib.$dll_extension ]; then @@ -77,4 +77,4 @@ cd $topdir # Print the summary. echo "================ Summary ================" -echo " KCLVM is updated into $install_dir" +echo " KCL is updated into $install_dir" diff --git a/scripts/release.sh b/scripts/release.sh index f4614b3cd..ad660bd1e 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,16 +1,29 @@ #!/usr/bin/env bash -if [ -z "$os" ]; then - os=$1 -fi +getSystemInfo() { + arch=$(uname -m) + case $arch in + armv7*) arch="arm";; + aarch64) arch="arm64";; + x86_64) arch="amd64";; + esac + + os=$(echo `uname`|tr '[:upper:]' '[:lower:]') +} -if [ -z "$os" ]; then - echo "Error: The variable 'os' is not set. Please set the 'os' variable before running the script." - exit 1 +if [ -z "$version" ]; then + version=$1 fi +if [ -z "$version" ]; then + version='latest' +fi + +getSystemInfo echo "[info] os: $os" -release_file="kclvm-$os-latest.tar.gz" +echo "[info] arch: $arch" +echo "[info] version: $version" +release_file="kclvm-$version-$os-$arch.tar.gz" release_path="$topdir/_build" package_dir="$topdir/_build/dist/$os" install_dir="kclvm"