summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/.github/workflows/release.yaml
blob: 4222266598ee3d036482c9fbad27745f66b8c089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# Copyright (c) the JPEG XL Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# Workflow for building the release binaries.
#
# This workflow runs as a post-submit step, when pushing to main or the release
# branches (v*.*.x), and when creating a release in GitHub.
#
# In the GitHub release case, in addition to build the release binaries it also
# uploads the binaries to the given release automatically.

name: Release build / deploy
on:
  push:
    branches:
      - main
      - v*.*.x
  release:
    types: [ published ]

jobs:
  ubuntu_static_x86_64:
    name: Release linux x86_64 static
    runs-on: [ubuntu-latest]
    steps:
    - name: Install build deps
      run: |
        sudo apt update
        sudo apt install -y \
          asciidoc \
          clang \
          cmake \
          doxygen \
          libbrotli-dev \
          libgdk-pixbuf2.0-dev \
          libgif-dev \
          libgtest-dev \
          libgtk2.0-dev  \
          libjpeg-dev \
          libopenexr-dev \
          libpng-dev \
          libwebp-dev \
          ninja-build \
          pkg-config \
        #
        echo "CC=clang" >> $GITHUB_ENV
        echo "CXX=clang++" >> $GITHUB_ENV

    - name: Checkout the source
      uses: actions/checkout@v2
      with:
        submodules: true
        fetch-depth: 1

    - name: Build
      env:
        SKIP_TEST: 1
      run: |
        ./ci.sh release \
          -DJPEGXL_DEP_LICENSE_DIR=/usr/share/doc \
          -DJPEGXL_STATIC=ON \
          -DBUILD_TESTING=OFF \
          -DJPEGXL_ENABLE_VIEWERS=OFF \
          -DJPEGXL_ENABLE_PLUGINS=OFF \
          -DJPEGXL_ENABLE_OPENEXR=OFF \

    - name: Package release tarball
      run: |
        cd build
        tar -zcvf ${{ runner.workspace }}/release_file.tar.gz \
          LICENSE* tools/{cjxl,djxl,benchmark_xl}
        ln -s ${{ runner.workspace }}/release_file.tar.gz \
          ${{ runner.workspace }}/jxl-linux-x86_64-static-${{ github.event.release.tag_name }}.tar.gz

    - name: Upload artifacts
      uses: actions/upload-artifact@v2
      with:
        name: jxl-linux-x86_64-static
        path: ${{ runner.workspace }}/release_file.tar.gz

    - name: Upload binaries to release
      if: github.event_name == 'release'
      uses: AButler/upload-release-assets@v2.0
      with:
        files: ${{ runner.workspace }}/jxl-linux-x86_64-static-${{ github.event.release.tag_name }}.tar.gz
        repo-token: ${{ secrets.GITHUB_TOKEN }}


  # Build .deb packages Ubuntu/Debian
  release_ubuntu_pkg:
    name: .deb packages / ${{ matrix.os }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        os:
        - ubuntu:20.04
        - ubuntu:18.04
        - debian:buster
        - debian:bullseye
        - debian:bookworm
        - debian:sid

    container:
      image: ${{ matrix.os }}

    steps:
    - name: Set env
      shell: 'bash'
      id: 'env'
      run: |
        artifact_name="jxl-debs-amd64-${matrix_os/:/-}"
        echo ${artifact_name}
        echo "::set-output name=artifact_name::${artifact_name}"
      env:
        matrix_os: ${{ matrix.os }}

    - name: Install build deps
      run: |
        apt update
        DEBIAN_FRONTEND=noninteractive apt install -y \
          build-essential \
          devscripts \
        #

    - name: Install git (only 18.04)
      if: matrix.os == 'ubuntu:18.04'
        # Ubuntu 18.04 ships with git 2.17 but we need 2.18 or newer for
        # actions/checkout@v2 to work
      shell: 'bash'
      run: |
        apt install -y \
          libcurl4-openssl-dev \
          libexpat1-dev \
          libssl-dev \
          wget \
          zlib1g-dev \
        #
        git_version="2.32.0"
        wget -nv \
          "https://github.com/git/git/archive/refs/tags/v${git_version}.tar.gz"
        tar -zxf "v${git_version}.tar.gz"
        cd "git-${git_version}"
        make prefix=/usr -j4 install

    - name: Install gcc-8 (only 18.04)
      if: matrix.os == 'ubuntu:18.04'
        # Compiler bug workaround: install and use gcc-8
      shell: 'bash'
      run: |
        apt install -y \
          gcc-8 \
          g++-8 \
        #
        update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100
        update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100
        update-alternatives --set g++ /usr/bin/g++-8
        update-alternatives --set gcc /usr/bin/gcc-8

    - name: Set git safe dir
      run: |
        export GIT_CEILING_DIRECTORIES=/__w # only work before git v2.35.2
        git config --global --add safe.directory /__w/libjxl/libjxl

    - name: Checkout the source
      uses: actions/checkout@v2
      with:
        submodules: true
        fetch-depth: 1

    - name: Stamp non-release versions
      # Stamps the built package with the commit date as part of the version
      # after the version number so newer release candidates can override older
      # ones.
      if: github.event_name != 'release'
      shell: 'bash'
      run: |
        # Committer timestamp.
        set -x
        commit_timestamp=$(git show -s --format=%ct)
        commit_datetime=$(date --utc "--date=@${commit_timestamp}" '+%Y%m%d%H%M%S')
        commit_ref=$(git rev-parse --short HEAD)
        sem_version=$(dpkg-parsechangelog --show-field Version)
        sem_version="${sem_version%%-*}"
        deb_version="${sem_version}~alpha${commit_datetime}-0+git${commit_ref}"
        dch -M --distribution unstable -b --newversion "${deb_version}" \
          "Stamping build with version ${deb_version}"

    - name: Stamp release versions
      # Mark the version as released
      if: github.event_name == 'release'
      shell: 'bash'
      run: |
        if head -n1 debian/changelog | grep UNRELEASED; then
          dch -M --distribution unstable --release ''
        fi

    - name: Install gtest (only 18.04)
      if: matrix.os == 'ubuntu:18.04'
        # In Ubuntu 18.04 no package installed the libgtest.a. libgtest-dev
        # installs the source files only.
      run: |
        apt install -y libgtest-dev cmake
        for prj in googletest googlemock; do
          (cd /usr/src/googletest/${prj}/ &&
           cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=/usr &&
           make all install)
        done
        # Remove libgmock-dev dependency in Ubuntu 18.04. It doesn't exist there.
        sed '/libgmock-dev,/d' -i debian/control

    - name: Install gmock-dev (debian:sid)
      # gtest-dev cmake depends on gmock-dev, but it is not installed by the
      # package.
      if: matrix.os == 'debian:sid'
      run: |
        apt install -y libgmock-dev

    - name: Remove libjxl-gimp-plugin package (only 18.04)
      if: matrix.os == 'ubuntu:18.04'
      run: |
        # Gimp 2.8 is not supported.
        sed -i '/Package: libjxl-gimp-plugin/,/^$/d' debian/control

    - name: Build hwy
      run: |
        apt build-dep -y ./third_party/highway
        ./ci.sh debian_build highway
        dpkg -i build/debs/libhwy-dev_*_amd64.deb

    - name: Build libjxl
      run: |
        apt build-dep -y .
        ./ci.sh debian_build jpeg-xl

    - name: Stats
      run: |
        ./ci.sh debian_stats

    - name: Upload artifacts
      uses: actions/upload-artifact@v2
      with:
        name: ${{ steps.env.outputs.artifact_name }}
        path: |
          build/debs/*jxl*.*

    - name: Package release tarball
      if: github.event_name == 'release'
      run: |
        (cd build/debs/; find -maxdepth 1 -name '*jxl*.*') | \
        tar -zcvf release_file.tar.gz -C build/debs/ -T -
        ln -s release_file.tar.gz \
          ${{ steps.env.outputs.artifact_name }}-${{ github.event.release.tag_name }}.tar.gz

    - name: Upload binaries to release
      if: github.event_name == 'release'
      uses: AButler/upload-release-assets@v2.0
      with:
        files: ${{ steps.env.outputs.artifact_name }}-${{ github.event.release.tag_name }}.tar.gz
        repo-token: ${{ secrets.GITHUB_TOKEN }}


  windows_build:
    name: Windows Build (vcpkg / ${{ matrix.triplet }})
    runs-on: [windows-2019]
    strategy:
      fail-fast: false
      matrix:
        include:
          - triplet: x86-windows-static
            arch: '-A Win32'
          - triplet: x64-windows-static
            arch: '-A x64'

    env:
      VCPKG_VERSION: '2022.06.16.1'
      VCPKG_ROOT: vcpkg
      VCPKG_DISABLE_METRICS: 1

    steps:
    - name: Checkout the source
      uses: actions/checkout@v2
      with:
        submodules: true
        fetch-depth: 2

    - uses: actions/cache@v2
      id: cache-vcpkg
      with:
        path: vcpkg
        key: release-${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.triplet }}

    - name: Download vcpkg
      if: steps.cache-vcpkg.outputs.cache-hit != 'true'
      # wget doesn't seem to work under bash.
      shell: 'powershell'
      run: |
        C:\msys64\usr\bin\wget.exe -nv `
           https://github.com/microsoft/vcpkg/archive/refs/tags/${{ env.VCPKG_VERSION }}.zip `
          -O vcpkg.zip
    - name: Bootstrap vcpkg
      if: steps.cache-vcpkg.outputs.cache-hit != 'true'
      shell: 'bash'
      run: |
        set -x
        unzip -q vcpkg.zip
        rm -rf ${VCPKG_ROOT}
        mv vcpkg-${VCPKG_VERSION} ${VCPKG_ROOT}
        ${VCPKG_ROOT}/bootstrap-vcpkg.sh

    - name: Install libraries with vcpkg
      shell: 'bash'
      run: |
        set -x
        ${VCPKG_ROOT}/vcpkg --triplet ${{ matrix.triplet }} install \
          giflib \
          libjpeg-turbo \
          libpng \
          libwebp \
        #

    - name: Configure
      shell: 'bash'
      run: |
        set -x
        mkdir build
        cmake -Bbuild -H. ${{ matrix.arch }} \
          -DBUILD_TESTING=OFF \
          -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_INSTALL_PREFIX=`pwd`/prefix \
          -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake \
          -DJPEGXL_ENABLE_OPENEXR=OFF \
          -DJPEGXL_ENABLE_PLUGINS=OFF \
          -DJPEGXL_ENABLE_TCMALLOC=OFF \
          -DJPEGXL_ENABLE_VIEWERS=OFF \
          -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} \
        #
    - name: Build
      shell: 'bash'
      run: |
        set -x
        cmake --build build --config Release
    - name: Install
      shell: 'bash'
      run: |
        set -x
        cmake --build build --config Release --target install
        for pkg in giflib libjpeg-turbo libpng libwebp zlib; do
          cp vcpkg/installed/${{matrix.triplet}}/share/${pkg}/copyright \
            prefix/bin/LICENSE.${pkg}
        done
        cp third_party/sjpeg/COPYING prefix/bin/LICENSE.sjpeg
        cp third_party/skcms/LICENSE prefix/bin/LICENSE.skcms
        cp third_party/highway/LICENSE prefix/bin/LICENSE.highway
        cp third_party/brotli/LICENSE prefix/bin/LICENSE.brotli
        cp LICENSE prefix/bin/LICENSE.libjxl
    - name: Upload artifacts
      uses: actions/upload-artifact@v2
      with:
        name: jxl-${{matrix.triplet}}
        path: |
          prefix/bin/*

    - name: Package release zip
      if: github.event_name == 'release'
      shell: 'powershell'
      run: |
        Compress-Archive -Path prefix\bin\* `
          -DestinationPath jxl-${{matrix.triplet}}.zip

    - name: Upload binaries to release
      if: github.event_name == 'release'
      uses: AButler/upload-release-assets@v2.0
      with:
        files: jxl-${{matrix.triplet}}.zip
        repo-token: ${{ secrets.GITHUB_TOKEN }}