From bda5da3c73fe8978a0f4b59d264ebfe8cd32fb0e Mon Sep 17 00:00:00 2001 From: LFC <990479+MichaelScofield@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:10:59 -0500 Subject: [PATCH] ci: release Windows artifacts (#2574) * ci: release Windows artifacts * ci: release Windows artifacts --- .../build-windows-artifacts/action.yml | 80 +++++++++++++++++++ .github/actions/upload-artifacts/action.yml | 14 +++- .github/workflows/release.yml | 42 ++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 .github/actions/build-windows-artifacts/action.yml diff --git a/.github/actions/build-windows-artifacts/action.yml b/.github/actions/build-windows-artifacts/action.yml new file mode 100644 index 000000000000..87eb3379dcee --- /dev/null +++ b/.github/actions/build-windows-artifacts/action.yml @@ -0,0 +1,80 @@ +name: Build Windows artifacts +description: Build Windows artifacts +inputs: + arch: + description: Architecture to build + required: true + rust-toolchain: + description: Rust toolchain to use + required: true + cargo-profile: + description: Cargo profile to build + required: true + features: + description: Cargo features to build + required: true + version: + description: Version of the artifact + required: true + disable-run-tests: + description: Disable running integration tests + required: true + artifacts-dir: + description: Directory to store artifacts + required: true +runs: + using: composite + steps: + - uses: arduino/setup-protoc@v1 + + - name: Install rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ inputs.rust-toolchain }} + targets: ${{ inputs.arch }} + components: llvm-tools-preview + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install PyArrow Package + shell: pwsh + run: pip install pyarrow + + - name: Install WSL distribution + uses: Vampire/setup-wsl@v2 + with: + distribution: Ubuntu-22.04 + + - name: Install latest nextest release # For integration tests. + if: ${{ inputs.disable-run-tests == 'false' }} + uses: taiki-e/install-action@nextest + + - name: Run integration tests + if: ${{ inputs.disable-run-tests == 'false' }} + shell: pwsh + run: make test sqlness-test + + - name: Upload sqlness logs + if: ${{ failure() }} # Only upload logs when the integration tests failed. + uses: actions/upload-artifact@v3 + with: + name: sqlness-logs + path: ${{ runner.temp }}/greptime-*.log + retention-days: 3 + + - name: Build greptime binary + shell: pwsh + run: cargo build --profile ${{ inputs.cargo-profile }} --features ${{ inputs.features }} --target ${{ inputs.arch }} + + - name: Upload artifacts + uses: ./.github/actions/upload-artifacts + with: + artifacts-dir: ${{ inputs.artifacts-dir }} + target-file: target/${{ inputs.arch }}/${{ inputs.cargo-profile }}/greptime + version: ${{ inputs.version }} diff --git a/.github/actions/upload-artifacts/action.yml b/.github/actions/upload-artifacts/action.yml index 290c9950509b..5c84619bf10a 100644 --- a/.github/actions/upload-artifacts/action.yml +++ b/.github/actions/upload-artifacts/action.yml @@ -33,9 +33,21 @@ runs: working-directory: ${{ inputs.working-dir }} shell: bash run: | - tar -zcvf ${{ inputs.artifacts-dir }}.tar.gz ${{ inputs.artifacts-dir }} && \ + tar -zcvf ${{ inputs.artifacts-dir }}.tar.gz ${{ inputs.artifacts-dir }} + + - name: Calculate checksum + if: runner.os != 'Windows' + working-directory: ${{ inputs.working-dir }} + shell: bash + run: | echo $(shasum -a 256 ${{ inputs.artifacts-dir }}.tar.gz | cut -f1 -d' ') > ${{ inputs.artifacts-dir }}.sha256sum + - name: Calculate checksum on Windows + if: runner.os == 'Windows' + working-directory: ${{ inputs.working-dir }} + shell: pwsh + run: Get-FileHash ${{ inputs.artifacts-dir }}.tar.gz -Algorithm SHA256 | select -ExpandProperty Hash > ${{ inputs.artifacts-dir }}.sha256sum + # Note: The artifacts will be double zip compressed(related issue: https://github.com/actions/upload-artifact/issues/39). # However, when we use 'actions/download-artifact@v3' to download the artifacts, it will be automatically unzipped. - name: Upload artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb69ae99129a..6d5534620958 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,11 @@ on: description: Build macos artifacts required: false default: false + build_windows_artifacts: + type: boolean + description: Build Windows artifacts + required: false + default: false publish_github_release: type: boolean description: Create GitHub release and upload artifacts @@ -97,6 +102,7 @@ jobs: linux-amd64-runner: ${{ steps.start-linux-amd64-runner.outputs.label }} linux-arm64-runner: ${{ steps.start-linux-arm64-runner.outputs.label }} macos-runner: ${{ inputs.macos_runner || vars.DEFAULT_MACOS_RUNNER }} + windows-runner: windows-latest-8-cores # The following EC2 resource id will be used for resource releasing. linux-amd64-ec2-runner-label: ${{ steps.start-linux-amd64-runner.outputs.label }} @@ -234,6 +240,42 @@ jobs: disable-run-tests: ${{ env.DISABLE_RUN_TESTS }} artifacts-dir: ${{ matrix.artifacts-dir-prefix }}-${{ needs.allocate-runners.outputs.version }} + build-windows-artifacts: + name: Build Windows artifacts + strategy: + fail-fast: false + matrix: + include: + - os: ${{ needs.allocate-runners.outputs.windows-runner }} + arch: x86_64-pc-windows-msvc + features: servers/dashboard + artifacts-dir-prefix: greptime-windows-amd64 + - os: ${{ needs.allocate-runners.outputs.windows-runner }} + arch: x86_64-pc-windows-msvc + features: pyo3_backend,servers/dashboard + artifacts-dir-prefix: greptime-windows-amd64-pyo3 + runs-on: ${{ matrix.os }} + needs: [ + allocate-runners, + ] + if: ${{ inputs.build_windows_artifacts || github.event_name == 'push' || github.event_name == 'schedule' }} + steps: + - run: git config --global core.autocrlf false + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: ./.github/actions/build-windows-artifacts + with: + arch: ${{ matrix.arch }} + rust-toolchain: ${{ env.RUST_TOOLCHAIN }} + cargo-profile: ${{ env.CARGO_PROFILE }} + features: ${{ matrix.features }} + version: ${{ needs.allocate-runners.outputs.version }} + disable-run-tests: ${{ env.DISABLE_RUN_TESTS }} + artifacts-dir: ${{ matrix.artifacts-dir-prefix }}-${{ needs.allocate-runners.outputs.version }} + release-images-to-dockerhub: name: Build and push images to DockerHub if: ${{ inputs.release_images || github.event_name == 'push' || github.event_name == 'schedule' }}