Browse Source

Refactor pip and cli CI/CD

tags/v0.3.5-fix3
haixuanTao 1 year ago
parent
commit
e3d9686474
2 changed files with 141 additions and 171 deletions
  1. +98
    -52
      .github/workflows/pip-release.yml
  2. +43
    -119
      .github/workflows/release.yml

+ 98
- 52
.github/workflows/pip-release.yml View File

@@ -19,46 +19,106 @@ permissions:

jobs:
linux:
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
target: [x86_64, x86, aarch64]
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
# - runner: ubuntu-latest
# target: s390x
# - runner: ubuntu-latest
# target: ppc64le
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Install dependencies
run: |
pip install patchelf --upgrade
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
target: ${{ matrix.platform.target }}
args: --release --out dist --zig
sccache: "true"
manylinux: auto
working-directory: apis/python/node
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.platform.target }}
path: apis/python/node/dist

musllinux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
target: x86_64
- runner: ubuntu-latest
target: x86
- runner: ubuntu-latest
target: aarch64
- runner: ubuntu-latest
target: armv7
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --zig
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: "true"
manylinux: musllinux_1_2
working-directory: apis/python/node
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: apis/python/node/dist

musleabi:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
[
{
target: "armv7-unknown-linux-musleabihf",
image_tag: "armv7-musleabihf",
},
]
container:
image: docker://messense/rust-musl-cross:${{ matrix.platform.image_tag }}
env:
CFLAGS_armv7_unknown_linux_musleabihf: "-mfpu=vfpv3-d16"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Build Wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: musllinux_1_2
container: off
args: --release -o dist
working-directory: apis/python/node
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
name: wheels-musllinux-${{ matrix.platform.target }}
path: apis/python/node/dist
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
tag: ${{ github.ref }}
file_glob: true

windows:
runs-on: ${{ matrix.platform.runner }}
@@ -66,14 +126,12 @@ jobs:
matrix:
platform:
- runner: windows-latest
target: x64
- runner: windows-latest
target: x86
target: x86_64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.7"
python-version: 3.8
architecture: ${{ matrix.platform.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
@@ -83,47 +141,37 @@ jobs:
sccache: "true"
working-directory: apis/python/node
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-windows-${{ matrix.platform.target }}
path: apis/python/node/dist
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
tag: ${{ github.ref }}
file_glob: true

macos:
runs-on: macos-latest
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
target: [x86_64, aarch64]
platform:
- runner: macos-12
target: x86_64
- runner: macos-14
target: aarch64
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
python-version: 3.8
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
target: ${{ matrix.platform.target }}
args: --release --out dist
sccache: "true"
working-directory: apis/python/node
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-macos-${{ matrix.platform.target }}
path: apis/python/node/dist
- name: Upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: apis/python/node/dist/*
tag: ${{ github.ref }}
file_glob: true

sdist:
runs-on: ubuntu-latest
@@ -145,15 +193,13 @@ jobs:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [linux, musllinux, musleabi, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- uses: actions/download-artifact@v4
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_PASS }}
with:
command: upload
args: --skip-existing *
args: --non-interactive --skip-existing *

+ 43
- 119
.github/workflows/release.yml View File

@@ -83,48 +83,59 @@ jobs:
cargo publish -p dora-record --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
cargo publish -p dora-rerun --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

windows-release:
name: "Windows Release"

unix:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform: [windows-2022]
platform:
- runner: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- runner: ubuntu-20.04
target: i686-unknown-linux-gnu
- runner: ubuntu-20.04
target: aarch64-unknown-linux-gnu
- runner: ubuntu-20.04
target: aarch64-unknown-linux-musl
- runner: ubuntu-20.04
target: armv7-unknown-linux-musleabihf
- runner: macos-12
target: aarch64-apple-darwin
- runner: macos-12
target: x86_64-apple-darwin
fail-fast: false
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3

- uses: r7kamura/rust-problem-matchers@v1.1.0

- name: "Build binaries"
timeout-minutes: 60
run: "cargo build --release -p dora-cli"

- name: Create Archive (Windows)
if: runner.os == 'Windows'
shell: powershell
- name: "Add toolchains"
run: rustup target add ${{ matrix.platform.target }}
- name: "Build"
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.platform.target }} -p dora-cli
- name: "Archive Linux"
run: |
New-Item -Path archive -ItemType Directory
Copy-Item target/release/dora.exe -Destination archive/dora.exe
Compress-Archive -Path archive\* -DestinationPath archive.zip

- name: "Upload release asset"
zip -r ${{ matrix.platform.target }}.zip target/ ${{ matrix.platform.target }}/release
- name: "Upload asset"
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: archive.zip
asset_name: dora-${{ github.ref_name }}-x86_64-${{ runner.os }}.zip
asset_path: ${{ matrix.platform.target }}.zip
asset_name: dora-${{ github.ref_name }}-${{ matrix.platform.target }}.zip
asset_content_type: application/zip

unix-release:
name: "Unix Release"
windows-release:
name: "Windows Release"

strategy:
matrix:
platform: [macos-12, ubuntu-20.04]
platform:
- runner: windows-2022
target: x86_64-pc-windows-msvc

fail-fast: false
runs-on: ${{ matrix.platform }}

@@ -137,14 +148,13 @@ jobs:
timeout-minutes: 60
run: "cargo build --release -p dora-cli"

- name: "Create Archive (Unix)"
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Create Archive (Windows)
if: runner.os == 'Windows'
shell: powershell
run: |
mkdir archive
cp target/release/dora archive/dora
cd archive
zip -r ../archive.zip .
cd ..
New-Item -Path archive -ItemType Directory
Copy-Item target/release/dora.exe -Destination archive/dora.exe
Compress-Archive -Path archive\* -DestinationPath archive.zip

- name: "Upload release asset"
uses: actions/upload-release-asset@v1.0.1
@@ -153,91 +163,5 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: archive.zip
asset_name: dora-${{ github.ref_name }}-x86_64-${{ runner.os }}.zip
asset_content_type: application/zip

linux-arm-release:
name: "Linux ARM Release"

strategy:
matrix:
platform: [ubuntu-20.04]
fail-fast: false
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3

- uses: r7kamura/rust-problem-matchers@v1.1.0

- name: "Build Linux ARM64"
if: runner.os == 'Linux'
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target aarch64-unknown-linux-gnu -p dora-cli

- name: "Archive Linux ARM64"
if: runner.os == 'Linux'
run: |
mkdir archive_aarch64
cp target/aarch64-unknown-linux-gnu/release/dora archive_aarch64/dora
cd archive_aarch64
zip -r ../archive_aarch64.zip .
cd ..

- name: "Upload Linux ARM64 asset"
if: runner.os == 'Linux'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: archive_aarch64.zip
asset_name: dora-${{ github.ref_name }}-aarch64-${{ runner.os }}.zip
asset_content_type: application/zip

mac-arm-release:
name: "MacOS ARM Release"

strategy:
matrix:
platform: [macos-12]
fail-fast: false
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3

- uses: r7kamura/rust-problem-matchers@v1.1.0
- name: "Add macOS ARM64 toolchains"
if: runner.os == 'macOS'
run: rustup target add aarch64-apple-darwin

- name: "Build macOS ARM64"
if: runner.os == 'macOS'
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target aarch64-apple-darwin -p dora-coordinator -p dora-cli -p dora-daemon

- name: "Archive macOS ARM64"
if: runner.os == 'macOS'
run: |
mkdir archive_aarch64
cp target/aarch64-apple-darwin/release/dora archive_aarch64/dora
cd archive_aarch64
zip -r ../archive_aarch64.zip .
cd ..

- name: "Upload macOS ARM64 asset"
if: runner.os == 'macOS'
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: archive_aarch64.zip
asset_name: dora-${{ github.ref_name }}-aarch64-${{ runner.os }}.zip
asset_name: dora-${{ github.ref_name }}-${{ matrix.platform.target }}.zip
asset_content_type: application/zip

Loading…
Cancel
Save