aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/lin_release.yml
blob: d233b2d178007f8f905fcee1449ddf221a67f2ec (plain) (blame)
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
env:
    QT_VERSION: '5.15.2'
    TCL_VERSION: '8.6'
    SQLITE_VERSION: '3470200'
    SQLITE_RELEASE_YEAR: '2024'
    PYTHON_VERSION: '3.9'
    PORTABLE_DIR: ${{ github.workspace }}/output/portable/SQLiteStudio
    INSTALLBUILDER_DIR: ../ib
    INSTALLBUILDER_URL: https://releases.installbuilder.com/installbuilder/installbuilder-enterprise-24.3.0-linux-x64-installer.run
    LIBSSL_DIR_URL: http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/
    LIBSSL_DEB: libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb

name: Linux release build

on:
    workflow_dispatch:
        inputs:
          use_ccache:
            description: 'Use ccache (for workflow debugging only!)'
            required: false
            type: boolean
    schedule:
        - cron: '30 3 * * 1' # run at 3:30 AM UTC every Monday
    repository_dispatch:
        types: [lin_release]

jobs:
    build:
        runs-on: ubuntu-20.04

        steps:
            - uses: actions/setup-python@v4
              with:
                python-version: ${{ env.PYTHON_VERSION }}
                architecture: 'x64'

            - name: Qt installation dir
              id: qt-installation-dir
              run: echo "DIR=$(readlink -f ${{ github.workspace }}/..)" >> $GITHUB_OUTPUT

            - name: Install Qt
              uses: jurplel/install-qt-action@v3
              with:
                cache: true
                version: ${{ env.QT_VERSION }}
                host: 'linux'
                dir: '${{ steps.qt-installation-dir.DIR }}'
                aqtversion: '==3.0.*'
                py7zrversion: '==0.20.*'
                setup-python: 'false'
                extra: '--external 7z'

            - name: Install the InstalBuilder
              shell: bash
              run: |
                curl -L ${{ env.INSTALLBUILDER_URL }} --output ib.run
                chmod +x ib.run
                ./ib.run --mode unattended --prefix ${{ env.INSTALLBUILDER_DIR }}
                ${{ env.INSTALLBUILDER_DIR }}/bin/builder --version
                echo "INSTALLER_SRC_PREFIX=$(pwd)" >> $GITHUB_ENV
                echo "INSTALLER_BIN_PREFIX=${{ env.PORTABLE_DIR }}" >> $GITHUB_ENV

            - name: Clone repo
              uses: actions/checkout@v3
              with:
                ref: ${{ github.event.client_payload.branch }}

            - name: Pre-download SQLite vanilla sourcecode
              shell: bash
              run: |
                cd ..
                curl -L http://sqlite.org/$SQLITE_RELEASE_YEAR/sqlite-src-$SQLITE_VERSION.zip --output sqlite-src-$SQLITE_VERSION.zip
                mkdir ext
                unzip sqlite-src-$SQLITE_VERSION.zip

                # Bugfix for #5145. The percentile extension was fixed, but the fix is not included in SQLite 3.47.1 source package.
                cd sqlite-src-$SQLITE_VERSION/ext
                rm -f misc/percentile.c
                curl -L https://sqlite.org/src/raw/82531c62cd015b9cdca95ad6bb10c3a907ceb570d21ebd4fb7d634c809cfb089?at=percentile.c --output misc/percentile.c

            - name: Prepare ccache
              if: inputs.use_ccache || false
              uses: hendrikmuhs/ccache-action@v1.2.8
              with:
                key: lin_release
                max-size: "24M"

            - name: Configure ccache
              if: inputs.use_ccache || false
              run: |
                echo "PATH=/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" >> $GITHUB_ENV

            - name: Install SQLite3
              run: |
                set -x
                sudo rm -f /usr/lib/libsqlite* /usr/local/lib/libsqlite* /usr/include/sqlite* /usr/local/include/sqlite* /usr/lib/x86_64-linux-gnu/libsqlite*
                wget http://sqlite.org/$SQLITE_RELEASE_YEAR/sqlite-amalgamation-$SQLITE_VERSION.zip
                unzip sqlite-amalgamation-$SQLITE_VERSION.zip
                cd sqlite-amalgamation-$SQLITE_VERSION
                gcc sqlite3.c -lpthread -ldl -lm -Os -fpic -shared -o libsqlite3.so \
                    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
                    -DSQLITE_ENABLE_DBSTAT_VTAB \
                    -DSQLITE_ENABLE_BYTECODE_VTAB \
                    -DSQLITE_ENABLE_COLUMN_METADATA \
                    -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
                    -DSQLITE_ENABLE_FTS3 \
                    -DSQLITE_ENABLE_FTS4 \
                    -DSQLITE_ENABLE_FTS5 \
                    -DSQLITE_ENABLE_GEOPOLY \
                    -DSQLITE_ENABLE_JSON1 \
                    -DSQLITE_ENABLE_RTREE \
                    -DSQLITE_ENABLE_MATH_FUNCTIONS
                strip libsqlite3.so
                ls -l
                sudo cp -P libsqlite3.so* /usr/local/lib/
                sudo cp *.h /usr/local/include/
                ls -l /usr/local/lib/libsqlite3*
                ls -l /usr/local/include/sqlite*

            - name: Compile additional SQLite3 extensions
              shell: bash
              run: |
                cd ../sqlite-src-$SQLITE_VERSION/ext
                FLAGS="-ldl -Os -fpic -shared -Imisc -I/usr/local/include -L/usr/local/lib -lsqlite3"
                for f in compress; do
                    echo "gcc misc/$f.c $FLAGS -lz -o ../../ext/$f.so"
                    gcc misc/$f.c $FLAGS -lz -o ../../ext/$f.so
                done
                for f in csv decimal eval ieee754 percentile rot13 series sqlar uint uuid zorder; do
                    echo "gcc misc/$f.c $FLAGS -o ../../ext/$f.so"
                    gcc misc/$f.c $FLAGS -o ../../ext/$f.so
                done
                for f in icu; do
                    echo "gcc icu/$f.c $FLAGS $(pkg-config --libs --cflags icu-uc icu-io) -o ../../ext/$f.so"
                    gcc icu/$f.c $FLAGS `pkg-config --libs --cflags icu-uc icu-io` -o ../../ext/$f.so
                done
                ls -l ../../ext/

            - name: Install Tcl
              run: sudo apt-get install -qq libtcl$TCL_VERSION tcl$TCL_VERSION-dev

            - name: Install other tools/dependencies
              run: |
                sudo apt install libreadline-dev libncurses5-dev patchelf chrpath
                echo "${{ github.workspace }}/../Qt/${{ env.QT_VERSION }}/gcc_64/bin" >> $GITHUB_PATH

            - name: Prepare output dir
              run: mkdir output output/build output/build/Plugins

            - name: Compile SQLiteStudio3
              working-directory: output/build
              run: |
                qmake \
                    $([ ${{ inputs.use_ccache || false }} = false ] || echo "CONFIG+=ccache") \
                    CONFIG+=portable \
                    ../../SQLiteStudio3
                make -j 2

            - name: Compile Plugins
              working-directory: output/build/Plugins
              run: |
                qmake \
                    $([ ${{ inputs.use_ccache || false }} = false ] || echo "CONFIG+=ccache") \
                    CONFIG+=portable \
                    "INCLUDEPATH+=$pythonLocation/include/python$PYTHON_VERSION" "LIBS += -L$pythonLocation/lib" \
                    ../../../Plugins
                make -j 1

            - name: Copy SQLite extensions to output dir
              shell: bash
              run: |
                cp -R ../ext output/SQLiteStudio/extensions

            - name: Prepare portable dir
              working-directory: output
              run: |
                mkdir portable
                cp -R SQLiteStudio portable/

            - name: Copy SQLite3 to portable dir
              working-directory: ${{ env.PORTABLE_DIR }}
              run: cp -P /usr/local/lib/libsqlite3.so* lib/

            - name: Copy SQLCipher's libcrypto to portable dir
              working-directory: ${{ env.PORTABLE_DIR }}
              run: |
                LIBCRYPTO=$(ldd plugins/libDbSqliteCipher.so | grep crypto | awk '{print $3}')
                REAL_LIBCRYPTO=$(readlink -e $LIBCRYPTO)
                cp -P $REAL_LIBCRYPTO lib/$(basename -- $LIBCRYPTO)

            - name: Copy Qt's libcrypto and libssl to portable dir (#4577)
              run: |
                wget ${{ env.LIBSSL_DIR_URL }}${{ env.LIBSSL_DEB }}
                dpkg-deb -xv ${{ env.LIBSSL_DEB }} .
                cp ./usr/lib/x86_64-linux-gnu/libssl.so.1.1 ${{ env.PORTABLE_DIR }}/lib/
                cp ./usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 ${{ env.PORTABLE_DIR }}/lib/

            - name: Copy Qt to portable dir
              working-directory: ${{ env.PORTABLE_DIR }}
              run: |
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Core.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5DBus.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Concurrent.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Gui.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Network.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5PrintSupport.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Qml.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5WaylandClient.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Widgets.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Xml.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5Svg.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libQt5XcbQpa.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libicui18n.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libicuuc.so* lib/
                cp -P ${{ env.Qt5_Dir }}/lib/libicudata.so* lib/

            - name: Copy Qt plugins to portable dir
              working-directory: ${{ env.PORTABLE_DIR }}
              run: |
                mkdir platforms imageformats iconengines printsupport platformthemes platforminputcontexts wayland-decoration-client wayland-graphics-integration-client wayland-shell-integration
                cp -P ${{ env.Qt5_Dir }}/plugins/platforms/libqxcb.so platforms/libqxcb.so
                cp -P ${{ env.Qt5_Dir }}/plugins/platforms/libqwayland-*.so platforms/
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqgif.so imageformats/libqgif.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqicns.so imageformats/libqicns.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqico.so imageformats/libqico.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqjpeg.so imageformats/libqjpeg.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqsvg.so imageformats/libqsvg.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqtga.so imageformats/libqtga.so
                cp -P ${{ env.Qt5_Dir }}/plugins/imageformats/libqtiff.so imageformats/libqtiff.so
                cp -P ${{ env.Qt5_Dir }}/plugins/iconengines/libqsvgicon.so iconengines/libqsvgicon.so
                cp -P ${{ env.Qt5_Dir }}/plugins/printsupport/libcupsprintersupport.so printsupport/libcupsprintersupport.so
                cp -P ${{ env.Qt5_Dir }}/plugins/platformthemes/libqgtk3.so platformthemes/libqgtk3.so
                cp -P ${{ env.Qt5_Dir }}/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so platforminputcontexts/libcomposeplatforminputcontextplugin.so
                cp -P ${{ env.Qt5_Dir }}/plugins/wayland-decoration-client/*.so wayland-decoration-client/
                cp -P ${{ env.Qt5_Dir }}/plugins/wayland-graphics-integration-client/*.so wayland-graphics-integration-client/
                cp -P ${{ env.Qt5_Dir }}/plugins/wayland-shell-integration/*.so wayland-shell-integration/
             
            - name: Fix dependency paths
              working-directory: ${{ env.PORTABLE_DIR }}
              run: |
                set -x
                chrpath -k -r \$ORIGIN/../lib   platforms/*.so imageformats/*.so iconengines/*.so printsupport/*.so platformthemes/*.so plugins/*.so wayland-*/*.so 2>&1 >/dev/null
                chrpath -k -r \$ORIGIN          lib/libicu*.*.*
                chrpath -k -r \$ORIGIN          lib/libcoreSQLiteStudio.so lib/libguiSQLiteStudio.so 2>&1 >/dev/null
                chrpath -k -r \$ORIGIN/lib      sqlitestudio 2>&1 >/dev/null
                chrpath -k -r \$ORIGIN/lib      sqlitestudiocli 2>&1 >/dev/null
                chrpath -l platforms/*.so imageformats/*.so iconengines/*.so printsupport/*.so platformthemes/*.so plugins/*.so
                chrpath -l lib/libicu*.*.*
                chrpath -l lib/libcoreSQLiteStudio.so lib/libguiSQLiteStudio.so
                chrpath -l sqlitestudio
                chrpath -l sqlitestudiocli

            - name: Final preparations for packaging
              run: |
                mkdir "${{ env.PORTABLE_DIR }}"/assets
                cp SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio_256.png "${{ env.PORTABLE_DIR }}"/assets/appicon.png
                cp SQLiteStudio3/guiSQLiteStudio/img/sqlitestudio.svg "${{ env.PORTABLE_DIR }}"/assets/appicon.svg

            - name: Final preparations for packaging
              working-directory: ${{ env.PORTABLE_DIR }}
              run: |
                cp `ldd sqlitestudiocli | grep readline | awk '{print $3}'` lib/
                cp `ldd lib/libreadline* | grep tinfo | awk '{print $3}'` lib/
                strip lib/*.so sqlitestudio sqlitestudiocli platforms/*.so imageformats/*.so iconengines/*.so printsupport/*.so platformthemes/*.so plugins/*.so
                # These may have no initial rpath/runpath so chrpath does not work on them
                patchelf --set-rpath '$ORIGIN' \
                  lib/libQt5Core.so.*.*.* \
                  lib/libreadline*

            - name: Determine SQLiteStudio version
              working-directory: ${{ env.PORTABLE_DIR }}
              run: echo "SQLITESTUDIO_VERSION=$(./sqlitestudiocli --version | cut -f 2 -d ' ')" >> $GITHUB_ENV

            - name: Assemble portable package
              shell: bash
              working-directory: ${{ env.PORTABLE_DIR }}/..
              run: |
                tar cf sqlitestudio-$SQLITESTUDIO_VERSION.tar SQLiteStudio
                xz -z sqlitestudio-$SQLITESTUDIO_VERSION.tar
                pwd
                ls -l

            - name: Create installer package
              shell: bash
              env:
                IB_LICENSE: ${{ secrets.INSTALLER_LICENSE }}
              run: |
                echo "$IB_LICENSE" > lic.xml
                ${{ env.INSTALLBUILDER_DIR }}/bin/builder build SQLiteStudio-installer.xml \
                    --license lic.xml \
                    --setvars project.outputDirectory=$(pwd) \
                    --setvars project.version=$SQLITESTUDIO_VERSION
                ls -l

            - name: SHA256 checksums
              shell: bash
              run: |
                sha256sum output/portable/sqlitestudio-${{ env.SQLITESTUDIO_VERSION }}.tar.xz
                sha256sum SQLiteStudio-${{ env.SQLITESTUDIO_VERSION }}-linux-x64-installer.run

            - name: Upload package artifact
              uses: actions/upload-artifact@v4
              with:
                name: sqlitestudio-${{ env.SQLITESTUDIO_VERSION }}.tar.xz
                path: output/portable/sqlitestudio-${{ env.SQLITESTUDIO_VERSION }}.tar.xz

            - name: Upload installer artifact
              uses: actions/upload-artifact@v4
              with:
                name: SQLiteStudio-${{ env.SQLITESTUDIO_VERSION }}-linux-x64-installer.run
                path: SQLiteStudio-${{ env.SQLITESTUDIO_VERSION }}-linux-x64-installer.run