Skip to content

Commit

Permalink
release CI: Windows artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
TianlongLiang committed Oct 10, 2024
1 parent deacb7a commit 0be9587
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .github/scripts/create_llvm_lib_cache_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
import sys

cache_key = sys.argv[1]

with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"key={cache_key}", file=f)
22 changes: 22 additions & 0 deletions .github/scripts/get_llvm_last_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import subprocess
import sys

# Get the repository root directory from the environment variable
repo_root = os.environ["GITHUB_WORKSPACE"]

# Change to the 'build-scripts' directory within the repository
build_scripts_dir = os.path.join(repo_root, "build-scripts")
os.chdir(build_scripts_dir)

gh_token = os.environ.get("GH_TOKEN", "")
extra_options = sys.argv[1:]

command = [sys.executable, "./build_llvm.py"] + extra_options + ["--llvm-ver"]
env = os.environ.copy()
env["GH_TOKEN"] = gh_token

result = subprocess.check_output(command, env=env, text=True).strip()

with open(os.environ["GITHUB_OUTPUT"], "a") as f:
print(f"last_commit={result}", file=f)
10 changes: 9 additions & 1 deletion .github/workflows/build_iwasm_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ jobs:
cmake --build build --config Release --parallel 4
working-directory: ${{ inputs.cwd }}

- name: compress the binary
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest'
run: |
tar -czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
Compress-Archive -Path iwasm -DestinationPath iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
working-directory: ${{ inputs.cwd }}/build

- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest'
run: |
tar czf iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
zip iwasm-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
Expand Down
45 changes: 36 additions & 9 deletions .github/workflows/build_llvm_libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: install dependencies for non macos-14
if: inputs.os != 'macos-14'
- name: install dependencies for non macos-14 and non Windows
if: inputs.os != 'macos-14' && inputs.os != 'windows-latest'
run: /usr/bin/env python3 -m pip install -r requirements.txt
working-directory: build-scripts

Expand All @@ -51,18 +51,28 @@ jobs:
run: /usr/bin/env python3 -m pip install -r requirements.txt --break-system-packages
working-directory: build-scripts

- name: retrieve the last commit ID
id: get_last_commit
run: echo "last_commit=$(GH_TOKEN=${{ secrets.GITHUB_TOKEN }} /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --llvm-ver)" >> $GITHUB_OUTPUT
- name: install dependencies (Windows)
if: inputs.os == 'windows-latest'
run: python -m pip install -r requirements.txt
working-directory: build-scripts

# Retrieve the last commit ID using a Python script for cross-platform compatibility
- name: Retrieve the last commit ID
id: get_last_commit
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python ./.github/scripts/get_llvm_last_commit.py ${{ inputs.extra_build_llvm_options }}
# Bump the prefix number to evict all previous caches and
# enforce a clean build, in the unlikely case that some
# weird build error occur and llvm/build becomes a potential
# suspect.
# suspect. TODO: Use Python script for cross-platform compatibility.
- name: form the cache key of libraries
id: create_lib_cache_key
run: echo "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}" >> $GITHUB_OUTPUT
run: |
python ./.github/scripts/create_llvm_lib_cache_key "key=0-llvm-libraries-${{ inputs.os }}-${{ inputs.arch }}-${{ steps.get_last_commit.outputs.last_commit }}${{ inputs.cache_key_suffix }}"
- name: Cache LLVM libraries
id: retrieve_llvm_libs
Expand Down Expand Up @@ -107,7 +117,24 @@ jobs:
- run: brew install ccache ninja
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && startsWith(inputs.os, 'macos')

- name: Build LLVM libraries
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true'
- uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: 0-ccache-${{ inputs.os }}-${{ steps.get_last_commit.outputs.last_commit }}
restore-keys: |
0-ccache-${{ inputs.os }}
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'

# Install tools on Windows
- run: choco install -y ccache ninja
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'

- name: Build LLVM libraries on non Windows
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os != 'windows-latest'
run: /usr/bin/env python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --arch ${{ inputs.arch }}
working-directory: build-scripts

- name: Build LLVM libraries on Windows
if: steps.retrieve_llvm_libs.outputs.cache-hit != 'true' && inputs.os == 'windows-latest'
run: python3 ./build_llvm.py ${{ inputs.extra_build_llvm_options }} --arch ${{ inputs.arch }}
working-directory: build-scripts
11 changes: 9 additions & 2 deletions .github/workflows/build_wamrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ jobs:
cmake --build build --config Release --parallel 4
working-directory: wamr-compiler

- name: compress the binary
if: inputs.release
- name: Compress the binary on Windows
if: inputs.runner == 'windows-latest' && inputs.release
run: |
tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
Compress-Archive -Path wamrc -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
working-directory: wamr-compiler/build

- name: compress the binary on non-Windows
if: inputs.runner != 'windows-latest' && inputs.release
run: |
tar czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/release_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ jobs:
os: "macos-13"
arch: "AArch64 ARM Mips RISCV X86"

build_llvm_libraries_on_windows:
needs: [create_tag, create_release]
uses: ./.github/workflows/build_llvm_libraries.yml
with:
os: "windows-latest"
arch: "AArch64 ARM Mips RISCV X86"

#
# WAMRC
release_wamrc_on_ubuntu_2004:
Expand Down Expand Up @@ -103,6 +110,16 @@ jobs:
runner: macos-13
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}

release_wamrc_on_windows:
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
uses: ./.github/workflows/build_wamrc.yml
with:
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
release: true
runner: windows-latest
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver }}

#
# IWASM
Expand Down Expand Up @@ -136,6 +153,16 @@ jobs:
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}

release_iwasm_on_windows:
needs: [create_tag, create_release, build_llvm_libraries_on_windows]
uses: ./.github/workflows/build_iwasm_release.yml
with:
cwd: product-mini/platforms/windows
llvm_cache_key: ${{ needs.build_llvm_libraries_on_windows.outputs.cache_key }}
runner: windows-latest
upload_url: ${{ needs.create_release.outputs.upload_url }}
ver_num: ${{ needs.create_tag.outputs.new_ver}}

#
# WAMR_SDK
release_wamr_sdk_on_ubuntu_2004:
Expand Down

0 comments on commit 0be9587

Please sign in to comment.