|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# This workflow is used for publish all rust based packages |
| 19 | + |
| 20 | +name: Release Dart |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + tags: |
| 25 | + - "*" |
| 26 | + pull_request: |
| 27 | + branches: |
| 28 | + - main |
| 29 | + paths: |
| 30 | + - ".github/workflows/release_dart.yml" |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | +jobs: |
| 41 | + build: |
| 42 | + runs-on: ${{ matrix.os }} |
| 43 | + strategy: |
| 44 | + matrix: |
| 45 | + include: |
| 46 | + - os: ubuntu-latest |
| 47 | + target: x86_64-unknown-linux-gnu |
| 48 | + target_suffix: x86_64 |
| 49 | + - os: ubuntu-latest |
| 50 | + target: aarch64-unknown-linux-gnu |
| 51 | + target_suffix: aarch64 |
| 52 | + - os: windows-latest |
| 53 | + target: x86_64-pc-windows-msvc |
| 54 | + target_suffix: win_x86_64 |
| 55 | + - os: macos-latest |
| 56 | + target: aarch64-apple-darwin |
| 57 | + target_suffix: macos_aarch64 |
| 58 | + steps: |
| 59 | + - name: Checkout code |
| 60 | + uses: actions/checkout@v3 |
| 61 | + - uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ~/.cargo/bin/ |
| 65 | + ~/.cargo/registry/index/ |
| 66 | + ~/.cargo/registry/cache/ |
| 67 | + ~/.cargo/git/db/ |
| 68 | + bindings/dart/rust/target/ |
| 69 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.target }} # Include target in cache key |
| 70 | + - name: Setup Rust toolchain |
| 71 | + uses: ./.github/actions/setup |
| 72 | + |
| 73 | + - name: Install cross |
| 74 | + run: cargo install cross --git https://github.com/cross-rs/cross --force |
| 75 | + |
| 76 | + - name: Build on linux |
| 77 | + if: runner.os == 'Linux' |
| 78 | + run: | |
| 79 | + cd bindings/dart/rust |
| 80 | + cross build --release --target ${{ matrix.target }} |
| 81 | +
|
| 82 | + - name: Build not on linux |
| 83 | + if: runner.os != 'Linux' |
| 84 | + run: | |
| 85 | + cd bindings/dart/rust |
| 86 | + cargo build --release --target ${{ matrix.target }} |
| 87 | +
|
| 88 | + - name: Upload build artifact (per platform) |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: ${{ matrix.target }} |
| 92 | + path: bindings/dart/rust/target/${{ matrix.target }}/release/*opendal* |
| 93 | + |
| 94 | + combine-artifacts: |
| 95 | + needs: build |
| 96 | + runs-on: ubuntu-latest |
| 97 | + steps: |
| 98 | + - name: Checkout code |
| 99 | + uses: actions/checkout@v3 |
| 100 | + - name: create release dir |
| 101 | + run: | |
| 102 | + cd bindings/dart/rust |
| 103 | + mkdir -p target/release/ |
| 104 | +
|
| 105 | + - name: Download all artifacts |
| 106 | + uses: actions/download-artifact@v4 |
| 107 | + with: |
| 108 | + path: artifacts |
| 109 | + |
| 110 | + - name: Move artifacts to release |
| 111 | + run: | |
| 112 | + cp -av ./artifacts/* bindings/dart/rust/target/release/ |
| 113 | + find . -name "*.a" -print -delete |
| 114 | + find . -name "*.d" -print -delete |
| 115 | + find . -name "*.pdb" -print -delete |
| 116 | + find . -name "*.exp" -print -delete |
| 117 | + find . -name "*.lib" -print -delete |
| 118 | + - name: Show Result |
| 119 | + run: | |
| 120 | + cd bindings/dart/rust |
| 121 | + ls -R . |
| 122 | + - name: Upload combined build artifacts |
| 123 | + uses: actions/upload-artifact@v4 |
| 124 | + with: |
| 125 | + name: combined-release |
| 126 | + path: bindings/dart/rust/target/release/ |
| 127 | +# todo: add pub step |
0 commit comments