From 33bb4508f32ab3a0f3e6aefb9b9aadfa212c905a Mon Sep 17 00:00:00 2001 From: peefy Date: Tue, 16 Jul 2024 13:20:05 +0800 Subject: [PATCH] ci: refactor artifact upload scripts Signed-off-by: peefy --- .github/workflows/build-test-centos7-amd64.yaml | 3 ++- .github/workflows/build-test-macos-arm64.yml | 6 ++++-- .github/workflows/build-test-ubuntu-arm64.yml | 11 ++++++++--- .github/workflows/macos_test.yaml | 6 ++++-- .github/workflows/ubuntu_test.yaml | 3 ++- .github/workflows/wasm_test.yaml | 1 + .github/workflows/windows_test.yaml | 3 ++- scripts/release.sh | 10 ++++++++++ 8 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-test-centos7-amd64.yaml b/.github/workflows/build-test-centos7-amd64.yaml index 6eb2e970c..6d7fe9a2e 100644 --- a/.github/workflows/build-test-centos7-amd64.yaml +++ b/.github/workflows/build-test-centos7-amd64.yaml @@ -33,7 +33,8 @@ jobs: /bin/bash -c "source ~/.bash_profile && export PATH=$PATH:/opt/build/bin/ && sed -i 's/llvm12/llvm7/g' kclvm/compiler/Cargo.toml && make && make release" - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: kcl-centos7-amd64 + if-no-files-found: error path: _build/kclvm-centos-latest.tar.gz diff --git a/.github/workflows/build-test-macos-arm64.yml b/.github/workflows/build-test-macos-arm64.yml index bd76c626f..0eb694759 100644 --- a/.github/workflows/build-test-macos-arm64.yml +++ b/.github/workflows/build-test-macos-arm64.yml @@ -4,7 +4,7 @@ on: ["push", "pull_request"] jobs: build-and-test: # Ref: https://github.com/actions/runner-images/tree/main/images/macos - # Note: The arch of macos-14 is arm64 + # Note: The arch of macos-13-xlarge and macos-14 is arm64 strategy: matrix: os: [macos-13-xlarge, macos-14] @@ -49,7 +49,9 @@ jobs: run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin:/opt/homebrew/opt/llvm@12/bin/ && make test-grammar-evaluator shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 + if: "contains(matrix.os, 'macos-13-xlarge')" with: name: kcl-darwin-arm64 + if-no-files-found: error path: _build/dist/Darwin/kclvm diff --git a/.github/workflows/build-test-ubuntu-arm64.yml b/.github/workflows/build-test-ubuntu-arm64.yml index 58719ccdf..43060c075 100644 --- a/.github/workflows/build-test-ubuntu-arm64.yml +++ b/.github/workflows/build-test-ubuntu-arm64.yml @@ -24,15 +24,20 @@ jobs: run: | docker pull --platform linux/arm64 kcllang/kcl-builder-arm64 - - name: Run custom ARM64 Docker image + - name: Build in Docker run: | docker run --rm --platform linux/arm64 \ -v ${{ github.workspace }}:/workspace -w /workspace \ kcllang/kcl-builder-arm64 \ - make && make release + /bin/bash -c "make && make release" + + - name: Release + shell: bash + run: os=ubuntu topdir=$PWD ./scripts/release.sh - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: kcl-linux-arm64 + if-no-files-found: error path: _build/kclvm-ubuntu-latest.tar.gz diff --git a/.github/workflows/macos_test.yaml b/.github/workflows/macos_test.yaml index fd84d5858..0c9eaae72 100644 --- a/.github/workflows/macos_test.yaml +++ b/.github/workflows/macos_test.yaml @@ -5,7 +5,7 @@ jobs: # Ref: https://github.com/actions/runner-images/tree/main/images/macos strategy: matrix: - os: [macos-11, macos-12, macos-13] + os: [macos-12, macos-13] runs-on: ${{ matrix.os }} steps: - name: Git checkout @@ -74,7 +74,9 @@ jobs: run: export PATH=$PATH:$PWD/../_build/dist/Darwin/kclvm/bin:/usr/local/opt/llvm@12/bin && make release shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 + if: "contains(matrix.os, 'macos-12')" with: name: kcl-darwin-amd64 + if-no-files-found: error path: _build/kclvm-Darwin-latest.tar.gz diff --git a/.github/workflows/ubuntu_test.yaml b/.github/workflows/ubuntu_test.yaml index 82cd9db9d..c7806a1db 100644 --- a/.github/workflows/ubuntu_test.yaml +++ b/.github/workflows/ubuntu_test.yaml @@ -59,7 +59,8 @@ jobs: run: export PATH=$PATH:$PWD/../_build/dist/ubuntu/kclvm/bin && make test shell: bash - - uses: actions/upload-artifact@v3 + - 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/wasm_test.yaml b/.github/workflows/wasm_test.yaml index 2b2396ecc..8e897f7b7 100644 --- a/.github/workflows/wasm_test.yaml +++ b/.github/workflows/wasm_test.yaml @@ -26,4 +26,5 @@ jobs: - uses: actions/upload-artifact@v3 with: name: kcl-wasm + if-no-files-found: error path: kclvm/target/wasm32-wasi/release/kclvm_cli_cdylib.wasm diff --git a/.github/workflows/windows_test.yaml b/.github/workflows/windows_test.yaml index 4ab0203c3..df06fda40 100644 --- a/.github/workflows/windows_test.yaml +++ b/.github/workflows/windows_test.yaml @@ -45,7 +45,8 @@ jobs: - run: cargo test -p kclvm-* --features llvm working-directory: ./kclvm - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: kcl-windows + if-no-files-found: error path: scripts/build-windows/_output/kclvm-windows diff --git a/scripts/release.sh b/scripts/release.sh index 5f26b861a..f4614b3cd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +if [ -z "$os" ]; then + os=$1 +fi + +if [ -z "$os" ]; then + echo "Error: The variable 'os' is not set. Please set the 'os' variable before running the script." + exit 1 +fi + +echo "[info] os: $os" release_file="kclvm-$os-latest.tar.gz" release_path="$topdir/_build" package_dir="$topdir/_build/dist/$os"