Skip to content

Commit

Permalink
ci: Improve Github Actions workflow
Browse files Browse the repository at this point in the history
This improves the existing workflow file for Github Actions by adding
SQLCipher support, fixing the unit tests, and making some other minor
adjustments.

Also a new workfile is added which build and uploads an AppImage. This
workfile skips some of the other build steps like running the tests.
  • Loading branch information
MKleusberg committed Dec 26, 2021
1 parent eb41e21 commit d396227
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 20 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: AppImage

on:
push:
branches: [master]
tags:
release:
types: ['created']

defaults:
run:
shell: bash

jobs:
build:
name: ${{ matrix.os }} - SQLCipher ${{ matrix.sqlcipher }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-18.04]
sqlcipher: ["0", "1"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install qttools5-dev libqt5scintilla2-dev libqcustomplot-dev libsqlite3-dev libqt5svg5 libsqlcipher-dev qt5-default
- name: Configure CMake
run: |
mkdir appbuild
mkdir appdir
cd appbuild
cmake -DCMAKE_INSTALL_PREFIX:PATH=../appdir/usr -Wno-dev -DFORCE_INTERNAL_QSCINTILLA=ON -Dsqlcipher=${{ matrix.sqlcipher }} -DSQLITE_ENABLE_JSON1=1 ..
- name: Run make
run: |
cd appbuild
make install
- name: Build AppImage
run: |
git rev-list master --count
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
export VERSION=$(printf "master-`git rev-list HEAD --count`-` git -C . rev-parse --short HEAD`")
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage
- name: Rename AppImage
if: ${{ matrix.sqlcipher == "1" }}
run: |
export FILE=$(ls DB_Browser_for_SQLite*.AppImage)
export FILE=${FILE/SQLite/SQLCipher}
mv DB_Browser_for_SQLite*.AppImage $FILE
- name: Upload to release page
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
find appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
chmod a+x upload.sh
UPLOADTOOL_ISPRERELEASE=true ./upload.sh DB_Browser_for_*.AppImage
41 changes: 21 additions & 20 deletions .github/workflows/cppcmake.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: C/C++ CI
name: CI

on:
push:
branches: ['*']
tags:
paths_ignore: ['docs/**', '.travis.yml']
pull_request:
branches: ['*']
release:
types: ['created']

Expand All @@ -15,57 +16,57 @@ defaults:

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.os }} - SQLCipher ${{ matrix.sqlcipher }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
config:
- {name: "ubuntu-20.04", os: "ubuntu-20.04"}

os: [ubuntu-20.04]
sqlcipher: ["0", "1"]
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install qttools5-dev libqt5scintilla2-dev libqcustomplot-dev libsqlite3-dev
sudo apt-get install qttools5-dev libqt5scintilla2-dev libqcustomplot-dev libsqlite3-dev libqt5svg5 libsqlcipher-dev
- name: Configure CMake
run: |
cmake --version
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PWD}/install \
-DCPACK_PACKAGE_DIRECTORY=${PWD}/package \
-DENABLE_TESTING=ON
- name: make
-DENABLE_TESTING=ON \
-Dsqlcipher=${{ matrix.sqlcipher }}
- name: Run make
run: cmake --build build --config Release -j --target install
- name: run tests
run: ctest -C Release
- name: package
run: ctest -V -C Release --test-dir build
- name: Package
run: |
cmake --build build --config Release -j --target package
cmake -E remove_directory package/_CPack_Packages
- name: upload package
- name: Upload package
uses: actions/upload-artifact@master
with:
name: pkg-${{ matrix.config.name }}
name: pkg-${{ matrix.os }}-sqlcipher${{ matrix.sqlcipher }}
path: package
- name: upload to release page
- name: Upload to release page
if: github.event_name == 'release'
env:
TOKEN: "token ${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
TAG: ${{ github.event.release.tag_name }}
UPLOAD_URL: ${{ github.event.release.upload_url }}
run: |
# Do try this at home! The REST API is documented at
# https://docs.github.com/en/free-pro-team@latest/rest and you can get a personal
# access token at https://github.com/settings/tokens
# (set TOKEN to "bearer abcdef1234")
# (set GITHUB_TOKEN to "bearer abcdef1234")
# you can get the UPLOAD_URL with a short bash snippet; make sure to set the env var TAG:
# UPLOAD_URL=$(curl -H 'Accept: application/vnd.github.v3+json' $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/$TAG | jq -r .upload_url)
UPLOAD_URL=${UPLOAD_URL%\{*} # remove "{name,label}" suffix
for pkg in package/*.*; do
NAME=$(basename $pkg)
MIME=$(file --mime-type $pkg|cut -d ' ' -f2)
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: $TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME
curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: $MIME" --data-binary @$pkg $UPLOAD_URL?name=$NAME
done

0 comments on commit d396227

Please sign in to comment.