openllm

Форк
0
/
binary-releases.yml 
286 строк · 10.6 Кб
1
# modified workflow from ofek/hatch, big kudos to them.
2
name: Standalone build
3
on:
4
  workflow_call:
5
  workflow_dispatch:
6
  push:
7
    branches: [main]
8
    paths-ignore:
9
      - '*.md'
10
      - 'docs/**'
11
      - 'bazel/**'
12
      - 'typings/**'
13
      - 'changelog.d/**'
14
      - 'assets/**'
15
      - 'openllm-node/**'
16
      - 'Formula/**'
17
  pull_request:
18
    branches: [main]
19
    paths-ignore:
20
      - '*.md'
21
      - 'docs/**'
22
      - 'bazel/**'
23
      - 'typings/**'
24
      - 'changelog.d/**'
25
      - 'assets/**'
26
      - 'openllm-node/**'
27
      - 'Formula/**'
28
defaults:
29
  run:
30
    shell: bash --noprofile --norc -exo pipefail {0}
31
concurrency:
32
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
33
  cancel-in-progress: true
34
env:
35
  APP_NAME: openllm
36
  PYOXIDIZER_VERSION: '0.24.0'
37
  HATCH_VERBOSE: 2
38
jobs:
39
  get_commit_message:
40
    name: Get commit message
41
    runs-on: ubuntu-latest
42
    if: "github.repository == 'bentoml/OpenLLM'" # Don't run on fork repository
43
    outputs:
44
      message: ${{ steps.commit_message.outputs.message }}
45
    steps:
46
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
47
        # Gets the correct commit message for pull request
48
        with:
49
          ref: ${{ github.event.pull_request.head.sha }}
50
      - name: Get commit message
51
        id: commit_message
52
        run: |
53
          set -xe
54
          COMMIT_MSG=$(git log --no-merges -1 --oneline)
55
          echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
56
          echo github.ref ${{ github.ref }}
57
  python-artifacts:
58
    name: Build wheel and source distribution
59
    runs-on: ubuntu-latest
60
    needs: get_commit_message
61
    if: >-
62
      contains(needs.get_commit_message.outputs.message, '[binary build]') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, '03 - Standalone Build')) || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')))
63
    steps:
64
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
65
        with:
66
          fetch-depth: 0
67
      - uses: bentoml/setup-bentoml-action@862aa8fa0e0c3793fcca4bfe7a62717a497417e4 # ratchet:bentoml/setup-bentoml-action@v1
68
        with:
69
          bentoml-version: 'main'
70
      - name: Pull latest change
71
        if: ${{ github.event_name != 'pull_request' }}
72
        run: git pull --autostash --no-edit --gpg-sign --ff origin main
73
      - name: Install build frontend
74
        run: python -m pip install --upgrade build
75
      - name: Build
76
        run: |
77
          bash local.sh
78
          python -m build -sw openllm-python/
79
      - name: Upload artifacts
80
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
81
        with:
82
          name: binary-artefacts
83
          path: openllm-python/dist/*
84
          if-no-files-found: error
85
  binaries:
86
    name: ${{ matrix.job.target }} (${{ matrix.job.os }})
87
    needs:
88
      - python-artifacts
89
    defaults:
90
      run:
91
        working-directory: openllm-python
92
    runs-on: ${{ matrix.job.os }}
93
    strategy:
94
      fail-fast: false
95
      matrix:
96
        job:
97
          # Linux
98
          - target: aarch64-unknown-linux-gnu
99
            os: ubuntu-22.04
100
            cross: true
101
          - target: x86_64-unknown-linux-gnu
102
            os: ubuntu-22.04
103
            cross: true
104
          - target: x86_64-unknown-linux-musl
105
            os: ubuntu-22.04
106
            cross: true
107
          - target: i686-unknown-linux-gnu
108
            os: ubuntu-22.04
109
            cross: true
110
          - target: powerpc64le-unknown-linux-gnu
111
            os: ubuntu-22.04
112
            cross: true
113
          # Windows
114
          # - target: x86_64-pc-windows-msvc
115
          #   os: windows-2022
116
          # - target: i686-pc-windows-msvc
117
          #   os: windows-2022
118
          # macOS
119
          - target: aarch64-apple-darwin
120
            os: macos-12
121
          - target: x86_64-apple-darwin
122
            os: macos-12
123
    outputs:
124
      version: ${{ steps.version.outputs.version }}
125
    env:
126
      CARGO: cargo
127
      CARGO_BUILD_TARGET: ${{ matrix.job.target }}
128
      PYAPP_REPO: pyapp
129
      PYAPP_VERSION: '0.10.1'
130
      PYAPP_PIP_EXTERNAL: 'true'
131
    steps:
132
      - name: Checkout code
133
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
134
        with:
135
          fetch-depth: 0
136
      - name: Pull latest change
137
        if: ${{ github.event_name != 'pull_request' }}
138
        run: git pull --autostash --no-edit --gpg-sign --ff origin main
139
      - name: Fetch PyApp
140
        run: >-
141
          mkdir $PYAPP_REPO && curl -L https://github.com/ofek/pyapp/releases/download/v$PYAPP_VERSION/source.tar.gz | tar --strip-components=1 -xzf - -C $PYAPP_REPO
142
      - name: Set up Python
143
        uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # ratchet:actions/setup-python@v5.0.0
144
        with:
145
          python-version-file: .python-version-default
146
      - name: Install Hatch
147
        run: pip install -U hatch
148
      - name: Install Rust toolchain
149
        uses: dtolnay/rust-toolchain@78c6b5541adb5849f5d72d15da722aedb26327ca # ratchet:dtolnay/rust-toolchain@stable
150
        with:
151
          targets: ${{ matrix.job.target }}
152
      - name: Set up cross compiling
153
        if: matrix.job.cross
154
        uses: taiki-e/install-action@5794068c211bc8f5f4514b7c3f03d6adbe66f1b7 # ratchet:taiki-e/install-action@v2.26.18
155
        with:
156
          tool: cross
157
      - name: Configure cross compiling
158
        if: matrix.job.cross
159
        run: echo "CARGO=cross" >> $GITHUB_ENV
160
      - name: Configure target
161
        run: |-
162
          config_file="$PYAPP_REPO/.cargo/config_${{ matrix.job.target }}.toml"
163
          if [[ -f "$config_file" ]]; then
164
            mv "$config_file" "$PYAPP_REPO/.cargo/config.toml"
165
          fi
166
      - name: Download Python artifacts
167
        if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
168
        uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
169
        with:
170
          name: binary-artefacts
171
          path: openllm-python/dist
172
      - name: Configure embedded project
173
        if: ${{ !startsWith(github.event.ref, 'refs/tags') }}
174
        run: |-
175
          cd dist
176
          wheel="$(echo *.whl)"
177
          mv "$wheel" "../$PYAPP_REPO"
178
          echo "PYAPP_PROJECT_PATH=$wheel" >> $GITHUB_ENV
179
      - name: Build binary
180
        run: hatch build --target app
181
      # Windows installers don't accept non-integer versions so we ubiquitously
182
      # perform the following transformation: X.Y.Z.devN -> X.Y.Z.N
183
      - name: Set project version
184
        id: version
185
        run: |-
186
          old_version="$(hatch version)"
187
          version="${old_version/dev/}"
188

189
          if [[ "$version" != "$old_version" ]]; then
190
            cd dist/app
191
            find . -type f -iname "openllm-*" | while read -r file; do
192
              binary=$(echo "$file" | sed 's/dev//')
193
              mv "$file" "$binary"
194
            done
195
          fi
196

197
          echo "version=$version" >> $GITHUB_OUTPUT
198
          echo "$version"
199
      - name: Archive binary
200
        run: |-
201
          mkdir packaging
202
          cd dist/app
203
          find . -type f -iname "openllm-*" | while read -r file; do
204
          if [[ "$file" =~ -pc-windows- ]]; then
205
            7z a "../../packaging/${file:0:-4}.zip" "$file"
206
          else
207
            binary="${file/dev/}"
208
            chmod +x "$file"
209
            tar -czf "../../packaging/$binary.tar.gz" "$file"
210
          fi
211
          done
212
      - name: Upload staged archive
213
        if: runner.os != 'Linux'
214
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
215
        with:
216
          name: staged-${{ runner.os }}
217
          path: openllm-python/packaging/*
218
          if-no-files-found: error
219
      - name: Upload archive
220
        if: runner.os == 'Linux'
221
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
222
        with:
223
          name: standalone
224
          path: openllm-python/packaging/*
225
          if-no-files-found: error
226
  windows-packaging:
227
    name: Build Windows installers
228
    needs: binaries
229
    if: false # ${{ github.event_name != 'pull_request' }}
230
    runs-on: windows-2022
231
    env:
232
      VERSION: ${{ needs.binaries.outputs.version }}
233
    defaults:
234
      run:
235
        working-directory: openllm-python
236
    steps:
237
      - name: Checkout code
238
        uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
239
      - name: Set up Python
240
        uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # ratchet:actions/setup-python@v5.0.0
241
        with:
242
          python-version-file: .python-version-default
243
      - name: Pull latest change
244
        run: git pull --autostash --no-edit --gpg-sign --ff origin main
245
      - name: Install PyOxidizer ${{ env.PYOXIDIZER_VERSION }}
246
        run: pip install pyoxidizer==${{ env.PYOXIDIZER_VERSION }}
247
      - name: Download staged binaries
248
        uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
249
        with:
250
          name: staged-${{ runner.os }}
251
          path: openllm-python/archives
252
      - name: Extract staged binaries
253
        run: |-
254
          mkdir -p bin
255
          for f in archives/*; do
256
            7z e "$f" -obin
257
          done
258
      # bin/<APP_NAME>-<VERSION>-<TARGET>.exe -> targets/<TARGET>/<APP_NAME>.exe
259
      - name: Prepare binaries
260
        run: |-
261
          mkdir -p targets
262
          for f in bin/*; do
263
            if [[ "$f" =~ openllm-${{ env.VERSION }}-(.+).exe$ ]]; then
264
              target="${BASH_REMATCH[1]}"
265
              mkdir -p "targets/$target"
266
              mv "$f" "targets/$target/${{ env.APP_NAME }}.exe"
267
            fi
268
          done
269
      - name: Build installers
270
        run: >-
271
          pyoxidizer build windows_installers --release --var version ${{ env.VERSION }}
272
      - name: Prepare installers
273
        run: |-
274
          mkdir installers
275
          mv build/*/release/*/*.{exe,msi} installers
276
      - name: Upload binaries
277
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
278
        with:
279
          name: standalone
280
          path: openllm-python/archives/*
281
          if-no-files-found: error
282
      - name: Upload installers
283
        uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
284
        with:
285
          name: installers
286
          path: openllm-python/installers/*
287

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.