Open
ci: 新增 Version-CI 和 Release-CI wheel 发布流水线 #197
BOCHENGZHANGAdd on 1 day ago
ci: 新增 Version-CI 和 Release-CI wheel 发布流水线 #197
Open
Total: 4 files changed+374-0
| @@ -0,0 +1,21 @@ | |||
| 1 | +name: Build wheel | ||
| 2 | +description: Build and validate the checked-out torchao-ascend source | ||
| 3 | + | ||
| 4 | +runs: | ||
| 5 | + using: composite | ||
| 6 | + steps: | ||
| 7 | + - name: Build and validate wheel | ||
| 8 | + shell: bash | ||
| 9 | + run: | | ||
| 10 | + set -euo pipefail | ||
| 11 | + test "$(uname -m)" = "${EXPECTED_ARCH:?Missing expected architecture}" | ||
| 12 | + build_script=".gitcode/actions/build-wheel/build_wheel.py" | ||
| 13 | + test -f "$build_script" | ||
| 14 | + test -f source/pyproject.toml | ||
| 15 | + build_env="$(mktemp -d)" | ||
| 16 | + trap 'rm -rf -- "$build_env"' EXIT | ||
| 17 | + "${PYTHON_EXECUTABLE:?Missing Python executable}" -m venv "$build_env" | ||
| 18 | + "$build_env/bin/python" -m pip install \ | ||
| 19 | + 'build==1.2.2.post1' 'packaging==24.2' 'setuptools==75.8.0' \ | ||
| 20 | + 'tomlkit==0.13.2' 'wheel==0.45.1' | ||
| 21 | + "$build_env/bin/python" "$build_script" source | ||
A.gitcode/actions/build-wheel/build_wheel.py+184-0File content is under review, please try again later
| @@ -0,0 +1,96 @@ | |||
| 1 | +name: Release-CI_torchao-ascend | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + workflow_dispatch: | ||
| 5 | + inputs: | ||
| 6 | + source_branch: | ||
| 7 | + description: Branch of Ascend/torchao-ascend to build | ||
| 8 | + type: string | ||
| 9 | + required: true | ||
| 10 | + release_stage: | ||
| 11 | + description: Release stage | ||
| 12 | + type: choice | ||
| 13 | + required: true | ||
| 14 | + default: release | ||
| 15 | + options: [release, alpha, beta, rc] | ||
| 16 | + release_number: | ||
| 17 | + description: Required for alpha, beta and rc; leave empty for release | ||
| 18 | + type: string | ||
| 19 | + required: false | ||
| 20 | + | ||
| 21 | +permissions: | ||
| 22 | + repository: read | ||
| 23 | + | ||
| 24 | +stages: | ||
| 25 | + package: | ||
| 26 | + name: Build Release wheel | ||
| 27 | + select: selected_by_default | ||
| 28 | + jobs: | ||
| 29 | + wheel: | ||
| 30 | + name: Build Release wheel | ||
| 31 | + runs-on: [self-hosted, default, arm, cpu=4] | ||
| 32 | + container: | ||
| 33 | + image: swr.cn-north-4.myhuaweicloud.com/frameworkptadapter/pytorch_2.11.0_a2_aarch64_builder:20260804 | ||
| 34 | + env: | ||
| 35 | + SOURCE_REPOSITORY: https://gitcode.com/Ascend/torchao-ascend.git | ||
| 36 | + SOURCE_BRANCH: ${{ inputs.source_branch }} | ||
| 37 | + EXPECTED_ARCH: aarch64 | ||
| 38 | + PYTHON_EXECUTABLE: python3.10 | ||
| 39 | + PIP_INDEX_URL: https://mirrors.huaweicloud.com/repository/pypi/simple | ||
| 40 | + PACKAGE_KIND: release | ||
| 41 | + BUILD_INFO: 'true' | ||
| 42 | + RELEASE_STAGE: ${{ inputs.release_stage }} | ||
| 43 | + RELEASE_NUMBER: ${{ inputs.release_number }} | ||
| 44 | + steps: | ||
| 45 | + - name: Checkout pipeline scripts from main | ||
| 46 | + uses: checkout | ||
| 47 | + with: | ||
| 48 | + ref: refs/heads/main | ||
| 49 | + persist-credentials: false | ||
| 50 | + | ||
| 51 | + - name: Checkout source to source | ||
| 52 | + run: | | ||
| 53 | + set -euo pipefail | ||
| 54 | + branch="${SOURCE_BRANCH:?Missing source branch}" | ||
| 55 | + source_ref="refs/heads/$branch" | ||
| 56 | + if ! git check-ref-format "$source_ref"; then | ||
| 57 | + printf 'Invalid source branch name: %q\n' "$branch" >&2 | ||
| 58 | + exit 1 | ||
| 59 | + fi | ||
| 60 | + git init source | ||
| 61 | + if ! git -C source fetch --no-tags --depth=1 "${SOURCE_REPOSITORY:?Missing source repository}" "$source_ref"; then | ||
| 62 | + printf 'Could not fetch %q. Check the branch and repository access.\n' "$source_ref" >&2 | ||
| 63 | + exit 1 | ||
| 64 | + fi | ||
| 65 | + git -C source checkout --detach FETCH_HEAD | ||
| 66 | + | ||
| 67 | + - name: Build and validate Release wheel | ||
| 68 | + uses: ./.gitcode/actions/build-wheel | ||
| 69 | + | ||
| 70 | + - name: Resolve Release archive directory | ||
| 71 | + id: archive | ||
| 72 | + run: | | ||
| 73 | + set -euo pipefail | ||
| 74 | + wheel=(source/output/target/torchao_ascend-*-py3-none-any.whl) | ||
| 75 | + if [[ ${#wheel[@]} -ne 1 || ! -f "${wheel[0]}" || ! -f "${wheel[0]%.whl}.json" ]]; then | ||
| 76 | + echo 'Expected one validated Release wheel and its JSON.' >&2 | ||
| 77 | + exit 1 | ||
| 78 | + fi | ||
| 79 | + version="${wheel[0]##*/}" | ||
| 80 | + version="${version#torchao_ascend-}" | ||
| 81 | + if ! [[ "$version" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(a[0-9]+|b[0-9]+|rc[0-9]+)?-py3-none-any\.whl$ ]]; then | ||
| 82 | + echo 'Could not resolve the Release base version from the wheel filename.' >&2 | ||
| 83 | + exit 1 | ||
| 84 | + fi | ||
| 85 | + printf 'base_version=%s\n' "${BASH_REMATCH[1]}" >> "${ATOMGIT_OUTPUT:?Missing step output file}" | ||
| 86 | + | ||
| 87 | + - name: Upload Release wheel and JSON to OBS | ||
| 88 | + uses: obs-upload | ||
| 89 | + with: | ||
| 90 | + endpoint: https://obs.cn-southwest-2.myhuaweicloud.com | ||
| 91 | + bucket: ascend-ci-artifacts-staging | ||
| 92 | + access-key: ${{ secrets.CI_ARTIFACTS_STAGING_AK }} | ||
| 93 | + secret-key: ${{ secrets.CI_ARTIFACTS_STAGING_SK }} | ||
| 94 | + artifact-path: source/output/target/* | ||
| 95 | + object-prefix: pypi/packages/ascend/repos/pypi/torchao-ascend/${{ steps.archive.outputs.base_version }}/ | ||
| 96 | + if-no-files-found: error | ||
| @@ -0,0 +1,73 @@ | |||
| 1 | +name: Version-CI_torchao-ascend | ||
| 2 | + | ||
| 3 | +concurrency: | ||
| 4 | + enable: true | ||
| 5 | + max: 3 | ||
| 6 | + exceed-action: QUEUE | ||
| 7 | + | ||
| 8 | +on: | ||
| 9 | + schedule: | ||
| 10 | + # Preserve the existing schedule: 01:00 UTC = 09:00 Asia/Shanghai. | ||
| 11 | + - cron: "0 1 * * *" | ||
| 12 | + workflow_dispatch: {} | ||
| 13 | + | ||
| 14 | +permissions: | ||
| 15 | + repository: read | ||
| 16 | + | ||
| 17 | +stages: | ||
| 18 | + package: | ||
| 19 | + name: Build Nightly wheel | ||
| 20 | + select: selected_by_default | ||
| 21 | + jobs: | ||
| 22 | + wheel: | ||
| 23 | + name: Build Nightly wheel | ||
| 24 | + runs-on: [self-hosted, default, arm, cpu=4] | ||
| 25 | + container: | ||
| 26 | + image: swr.cn-north-4.myhuaweicloud.com/frameworkptadapter/pytorch_2.11.0_a2_aarch64_builder:20260804 | ||
| 27 | + env: | ||
| 28 | + SOURCE_REPOSITORY: https://gitcode.com/Ascend/torchao-ascend.git | ||
| 29 | + SOURCE_BRANCH: main | ||
| 30 | + EXPECTED_ARCH: aarch64 | ||
| 31 | + PYTHON_EXECUTABLE: python3.10 | ||
| 32 | + PIP_INDEX_URL: https://mirrors.huaweicloud.com/repository/pypi/simple | ||
| 33 | + BUILD_IMAGE: swr.cn-north-4.myhuaweicloud.com/frameworkptadapter/pytorch_2.11.0_a2_aarch64_builder:20260804 | ||
| 34 | + PIPELINE_RUN_ID: ${{ atomgit.workflow_run_id }} | ||
| 35 | + PACKAGE_KIND: nightly | ||
| 36 | + BUILD_INFO: 'false' | ||
| 37 | + steps: | ||
| 38 | + - name: Checkout pipeline scripts from main | ||
| 39 | + uses: checkout | ||
| 40 | + with: | ||
| 41 | + ref: refs/heads/main | ||
| 42 | + persist-credentials: false | ||
| 43 | + | ||
| 44 | + - name: Checkout source to source | ||
| 45 | + run: | | ||
| 46 | + set -euo pipefail | ||
| 47 | + branch="${SOURCE_BRANCH:?Missing source branch}" | ||
| 48 | + source_ref="refs/heads/$branch" | ||
| 49 | + git check-ref-format "$source_ref" | ||
| 50 | + git init source | ||
| 51 | + git -C source fetch --no-tags --depth=1 "${SOURCE_REPOSITORY:?Missing source repository}" "$source_ref" | ||
| 52 | + git -C source checkout --detach FETCH_HEAD | ||
| 53 | + | ||
| 54 | + - name: Build and validate Nightly wheel | ||
| 55 | + uses: ./.gitcode/actions/build-wheel | ||
| 56 | + | ||
| 57 | + - name: Upload Nightly build information | ||
| 58 | + uses: upload-artifact | ||
| 59 | + with: | ||
| 60 | + name: torchao-ascend-nightly-build-info | ||
| 61 | + path: source/output/target/build-info.txt | ||
| 62 | + if-no-files-found: error | ||
| 63 | + | ||
| 64 | + - name: Upload Nightly wheel to OBS | ||
| 65 | + uses: obs-upload | ||
| 66 | + with: | ||
| 67 | + endpoint: https://obs.cn-southwest-2.myhuaweicloud.com | ||
| 68 | + bucket: ascend-ci-artifacts-staging | ||
| 69 | + access-key: ${{ secrets.CI_ARTIFACTS_STAGING_AK }} | ||
| 70 | + secret-key: ${{ secrets.CI_ARTIFACTS_STAGING_SK }} | ||
| 71 | + artifact-path: source/output/target/*.whl | ||
| 72 | + object-prefix: pypi/packages/ascend/repos/pypi/nightly/torchao-ascend/ | ||
| 73 | + if-no-files-found: error | ||