aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: c1fc1421876533db04d53aa28973b5462c1532f3 (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
name: CI

on:
  push:
  pull_request:
    branches:
      - '*'
  workflow_dispatch:
    inputs:
      version:
        description: Release Version
        required: false
      buildtype:
        description: Release build type
        type: choice
        default: release
        options:
          - debug
          - debugoptimized
          - release

# Builds & Uploads:
# * Linux x86_64 Portable
# * Linux App Image
# * Mac Universal Portable
# * Mac Universal DMG
# * Windows x86_64 Portable
# * Windows x86_64 Installer
jobs:
  # Checks to see if we have an input, and stamps that onto the repo.
  # Determines if this is a release, and determines the official ref.
  version:
    name: Compute Version & Check for Release
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    outputs:
      buildtype: ${{ steps.check_release.outputs.buildtype }}
      release: ${{ steps.check_release.outputs.release }}
      ref: ${{ steps.check_release.outputs.ref }}
    permissions:
      contents: write
    steps:
      - name: Update Tag
        uses: richardsimko/update-tag@v1
        if: ${{ github.event.inputs.version }}
        with:
          tag_name: ${{ github.event.inputs.version }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
          fetch-tags: true

      - name: Check Release
        id: check_release
        env: { BUILDTYPE: "${{ github.event.inputs.buildtype }}" }
        run: |
          if [[ $GITHUB_REF == refs/pull/* || ( $GITHUB_REF != refs/heads/master && $GITHUB_REF != refs/tags/* ) ]]; then
            export BUILDTYPE="debugoptimized"
          elif [[ -z $BUILDTYPE ]]; then
            export BUILDTYPE="release"
          fi
          REF=$(git describe --exact-match --match v[0-9]* HEAD --tags 2>/dev/null) || REF=continuous
          echo "ref=$REF" >> $GITHUB_OUTPUT
          echo "buildtype=$BUILDTYPE" >> $GITHUB_OUTPUT
          echo "Build Version: $REF"
          echo "Build Type: $BUILDTYPE"
          if [[ "$REF" != "continuous" ]]; then
            echo "release=$REF" >> $GITHUB_OUTPUT
            echo "Release Version: $REF"
          fi


  build_darwin:
    name: Darwin
    needs: [version]
    strategy:
      matrix:
        config:
          - { runner: macos-15-intel, arch: x86_64-darwin }
          - { runner: macos-15, arch: aarch64-darwin }
    runs-on: ${{ matrix.config.runner }}
    steps:
      - name: System Information
        run: |
          system_profiler SPSoftwareDataType
          bash --version
          gcc -v
          xcodebuild -version

      - uses: actions/checkout@v5

      - name: Python Setup
        uses: actions/setup-python@v6
        with: { python-version: "3.11" }

      - name: Install Dependencies
        run: |
          brew install bash
          pip3 install meson ninja

      - name: Build & Package Mac (Bundle)
        run: |
          scripts/build.sh --addons --debug --forcefallback --reconfigure --lto --bundle --mode ${{ needs.version.outputs.buildtype }} -b build
          tar -C build -czvf lite-xl-${{ needs.version.outputs.ref }}-${{ matrix.config.arch }}-bundle.tar.gz "Lite XL.app"

      - name: Build & Package Mac (Portable)
        run: |
          scripts/build.sh --addons --debug --forcefallback --reconfigure --lto --portable --mode ${{ needs.version.outputs.buildtype }} -b build
          tar -C build -czvf lite-xl-${{ needs.version.outputs.ref }}-${{ matrix.config.arch }}-portable.tar.gz lite-xl

      - name: Upload (Intermediate)
        uses: actions/upload-artifact@v5
        with:
          name: lite-xl-${{ needs.version.outputs.ref }}-${{ matrix.config.arch }}
          path: |
            *.tar.gz


  build_darwin_universal:
    name: Darwin (Universal)
    needs: [version, build_darwin]
    runs-on: macos-15
    steps:
      - uses: actions/checkout@v5

      - name: Python Setup
        uses: actions/setup-python@v6
        with: { python-version: "3.11" }

      - name: Install Dependencies
        run: |
          brew install bash
          pip3 install dmgbuild

      - name: Download Artifacts
        uses: actions/download-artifact@v6
        with:
          pattern: '*darwin*'
          merge-multiple: true

      - name: Create Universal Binaries
        run: |
          REF="lite-xl-${{ needs.version.outputs.ref }}"
          for TYPE in bundle portable; do
            mkdir -p $REF-universal-darwin-$TYPE package-$TYPE/{x86_64,aarch64}
            tar -C package-$TYPE/x86_64 -zxvf $REF-x86_64-darwin-$TYPE.tar.gz
            tar -C package-$TYPE/aarch64 -zxvf $REF-aarch64-darwin-$TYPE.tar.gz
            cp -a package-$TYPE/*/* $REF-universal-darwin-$TYPE
            find package-$TYPE -type f -name lite-xl -perm +111 -print0 | \
              xargs -0 lipo -create -output "$(find $REF-universal-darwin-$TYPE -type f -name lite-xl -perm +111)"
          done

      - name: Package Darwin (Universal DMG Image)
        run: |
          dmgbuild -s resources/macos/lite-xl-dmg.py \
            -D "app_path=lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-bundle/Lite XL.app" \
            "Lite XL" "lite-xl-${{ needs.version.outputs.ref }}-universal-darwin.dmg"

      - name: Package Darwin (Universal Portable)
        run: tar -C lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable -zcvf lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable.tar.gz .

      - name: Upload (Release)
        uses: actions/upload-artifact@v5
        with:
          name: lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-release
          path: |
            lite-xl-${{ needs.version.outputs.ref }}-universal-darwin.dmg
            lite-xl-${{ needs.version.outputs.ref }}-universal-darwin-portable.tar.gz


  build_linux:
    name: Linux (x86_64)
    needs: [version]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Build
        uses: docker://ghcr.io/lite-xl/lite-xl-build-box-manylinux:v4
        with:
          entrypoint: /entrypoint.sh
          args: bash scripts/build.sh --addons --debug --forcefallback --lto --portable --mode ${{ needs.version.outputs.buildtype }} -b build

      - name: Package Linux (Portable)
        run: tar -C build -czvf lite-xl-${{ needs.version.outputs.ref }}-x86_64-linux-portable.tar.gz lite-xl

      - name: Package Linux (AppImage)
        uses: docker://ghcr.io/lite-xl/lite-xl-build-box-manylinux:v4
        with:
          entrypoint: /entrypoint.sh
          run: bash scripts/package-appimage.sh --debug --version ${{ needs.version.outputs.ref }} -b build

      - name: Upload (Release)
        uses: actions/upload-artifact@v5
        with:
          name: lite-xl-${{ needs.version.outputs.ref }}-x86_64-linux-portable-release
          path: |
            *.tar.gz
            *.AppImage


  build_windows:
    name: Windows (x86_64) (MSYS)
    runs-on: windows-2022
    defaults:
      run:
        shell: msys2 {0}
    needs: [version]
    steps:
      - uses: msys2/setup-msys2@v2
        with:
          msystem: MINGW64
          install: >-
            git
            zip
            patch
          pacboy: >-
            gcc:p
            meson:p
            cmake:p
            ninja:p
            pkg-config:p
            ca-certificates:p

      - uses: actions/checkout@v5

      - name: Build
        run: bash scripts/build.sh --addons --debug --forcefallback --lto --portable --mode ${{ needs.version.outputs.buildtype }} -b build

      - name: Package Windows (Portable)
        run: cd build && zip -r ../lite-xl-${{ needs.version.outputs.ref }}-x86_64-windows-portable.zip lite-xl && cd ..

      - name: Package Windows (InnoSetup)
        run: bash scripts/package-innosetup.sh --debug --version ${{ needs.version.outputs.ref }} -b build

      - name: Upload (Release)
        uses: actions/upload-artifact@v5
        with:
          name: lite-xl-${{ needs.version.outputs.ref }}-x86_64-windows-portable-release
          path: |
            *.zip
            *.exe


  build_windows_msvc:
    name: Windows (x86_64) (MSVC)
    needs: [version]
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v5

      - name: Setup MSVC
        id: msvc-dev-cmd
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: x86_64

      - name: Setup Python
        uses: actions/setup-python@v6
        with: { python-version: "3.11" }

      - name: Install meson and ninja
        run: pip install --no-cache-dir meson ninja

      - name: Export GitHub Actions cache environment variables
        uses: actions/github-script@v8
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
              
      - name: Install pkgconf
        env: { VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" }
        run: vcpkg install pkgconf:x64-windows-release

      # https://github.com/ilammy/msvc-dev-cmd?tab=readme-ov-file#name-conflicts-with-shell-bash
      - name: Set environment variables
        run: |
          echo "PKG_CONFIG=C:\vcpkg\installed\x64-windows-release\tools\pkgconf\pkgconf.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
          echo "CC_LD=$((Get-Command link.exe).Source)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

      - name: Build
        run: bash scripts/build.sh --addons --debug --forcefallback --lto --portable --mode ${{ needs.version.outputs.buildtype }} -b build

      - name: Package
        run: cd build && 7z a -mx=9 "..\lite-xl-${{ needs.version.outputs.ref }}-x86_64-windows.zip" lite-xl && cd ..

      - name: Upload Artifacts (Intermediate)
        uses: actions/upload-artifact@v5
        with:
          name: lite-xl-${{ needs.version.outputs.ref }}-x86_64-windows (MSVC)
          compression-level: 0
          path: |
            *.zip


  release:
    name: Create Release
    needs: [version, build_linux, build_windows, build_darwin_universal]
    runs-on: ubuntu-latest
    if: ${{ needs.version.outputs.release || github.ref == 'refs/heads/master' }}
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v5
      - name: Download Artifacts
        uses: actions/download-artifact@v6
        with:
          pattern: lite-xl-*-release
          merge-multiple: true
          path: releases
      - name: Generate Release Notes
        if: needs.version.outputs.release
        env:
          GH_TOKEN: ${{ github.token }}
        run: bash scripts/generate-release-notes.sh --version ${{ needs.version.outputs.release }}
      - name: Versioned Release
        uses: ncipollo/release-action@v1
        if: ${{ needs.version.outputs.release }}
        with:
          tag: ${{ needs.version.outputs.release }}
          name: Lite XL ${{ needs.version.outputs.release }}
          draft: true
          allowUpdates: true
          bodyFile: release-notes.md
          artifacts: "releases/*.*"
      - name: Update Tag
        uses: richardsimko/update-tag@v1
        if: github.ref == 'refs/heads/master'
        with:
          tag_name: continuous
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Continuous Release
        uses: ncipollo/release-action@v1
        if: github.ref == 'refs/heads/master'
        with:
          name: Lite XL Continuous Release
          tag: continuous
          prerelease: true
          allowUpdates: true
          removeArtifacts: true
          generateReleaseNotes: true
          artifacts: "releases/*.*"