From ff906330d103fe3346f68f0632206f3fb562bbc7 Mon Sep 17 00:00:00 2001
From: Fabien Poussin <fabien.poussin@gmail.com>
Date: Mon, 28 Oct 2024 14:28:04 +0100
Subject: [PATCH] Switch to Gitlab Actions

---
 .github/workflows/build.yml | 143 ++++++++++++++++++++++++++++++++++++
 .travis.yml                 |  12 ---
 CMakeLists.txt              |   2 +-
 Jenkinsfile                 |  38 ----------
 README.md                   |   7 +-
 appveyor.yml                |  75 -------------------
 6 files changed, 147 insertions(+), 130 deletions(-)
 create mode 100644 .github/workflows/build.yml
 delete mode 100644 .travis.yml
 delete mode 100644 Jenkinsfile
 delete mode 100644 appveyor.yml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..68ef8e4
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,143 @@
+name: QMake Build Matrix
+
+on: [push]
+
+env:
+  QT_VERSION: 6.8.0
+
+jobs:
+  build:
+    name: ${{ matrix.config.name }}
+    runs-on: ${{ matrix.config.os }}
+    strategy:
+      matrix:
+        config:
+          - name: "Linux Latest x64"
+            artifact: "Linux-x64.zip"
+            arch: ""
+            os: ubuntu-latest
+          # - name: "macOS Latest x64"
+          #   artifact: "macOS-x64.zip"
+          #   arch: ""
+          #   os: macos-latest
+          # - name: "Windows Latest x64"
+          #   artifact: "Windows-x64.zip"
+          #   arch: win64_msvc2022_64
+          #   os: windows-latest
+          #   environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
+
+    steps:
+    - uses: actions/checkout@v1
+
+    - name: Installing system libs on Linux
+      if: runner.os == 'Linux'
+      shell: cmake -P {0}
+      run: |
+        if ("${{ runner.os }}" STREQUAL "Linux")
+          execute_process(
+            COMMAND sudo apt install libusb-1.0-0-dev libhidapi-dev
+          )
+        endif()
+
+    - name: Installing system libs on Windows
+      if: runner.os == 'Windows'
+      run: ""
+
+    - name: Installing system libs on MacOS
+      if: runner.os == 'macOS'
+      run: ""
+
+    - name: Download Qt
+      id: qt
+      uses: jurplel/install-qt-action@v4
+      with:
+        version: "${{ env.QT_VERSION }}"
+        arch: "${{ matrix.config.arch }}"
+
+    - name: Configure
+      run: |
+        cmake -S . -B build
+
+    - name: Build
+      run: |
+        cd build
+        make -j $(nproc)
+        
+    - uses: actions/upload-artifact@v4
+      id: upload_artifact
+      with:
+        path: ./qtusb-${{ matrix.config.artifact }}
+        name: qtusb-${{ matrix.config.artifact }}
+
+  release:
+    if: contains(github.ref, 'tags/v')
+    runs-on: ubuntu-latest
+    needs: build
+
+    steps:
+    - name: Create Release
+      id: create_release
+      uses: actions/create-release@v1.0.0
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      with:
+        tag_name: ${{ github.ref }}
+        release_name: Release ${{ github.ref }}
+        draft: false
+        prerelease: false
+
+    - name: Store Release url
+      run: |
+        echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url
+
+    - uses: actions/upload-artifact@v1
+      with:
+        path: ./upload_url
+        name: upload_url
+
+  publish:
+    if: contains(github.ref, 'tags/v')
+
+    name: "Publish ${{ matrix.config.name }}"
+    runs-on: ${{ matrix.config.os }}
+    strategy:
+      matrix:
+        config:
+          - name: "Linux Latest x64"
+            artifact: "Linux-x64.zip"
+            os: ubuntu-latest
+          # - name: "macOS Latest x64"
+          #   artifact: "macOS-x64.zip"
+          #   os: macos-latest
+          # - name: "Windows Latest x64"
+          #   artifact: "Windows-x64.zip"
+          #   os: windows-latest
+    needs: release
+
+    steps:
+    - name: Download artifact
+      uses: actions/download-artifact@v1
+      with:
+        name: ${{ env.PLUGIN_NAME }}-${{ env.QT_CREATOR_VERSION }}-${{ matrix.config.artifact }}
+        path: ./
+
+    - name: Download URL
+      uses: actions/download-artifact@v1
+      with:
+        name: upload_url
+        path: ./
+    - id: set_upload_url
+      run: |
+        upload_url=`cat ./upload_url`
+        echo ::set-output name=upload_url::$upload_url
+
+    - name: Upload to Release
+      id: upload_to_release
+      uses: actions/upload-release-asset@v1.0.1
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      with:
+        upload_url: ${{ steps.set_upload_url.outputs.upload_url }}
+        asset_path: ./qtusb-${{ matrix.config.artifact }}
+        asset_name: qtusb}-${{ matrix.config.artifact }}
+        asset_content_type: application/zip
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index e34a846..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-sudo: required
-dist: xenial
-language: cpp
-compiler: gcc
-install:
-  - sudo apt-get update -qq
-  - sudo apt-get -qq install qtbase5-dev qt5-qmake qt5-default libusb-1.0-0-dev qtbase5-private-dev
-
-script:
-  - qmake
-  - make -j $(nproc)
-  - sudo make install
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31bb763..8f419e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16)
 
 include(.cmake.conf)
 project(QtUsb
-    VERSION         6.4.0 # FIXME: this needs to match host's Qt version
+    VERSION         6.8.0 # FIXME: this needs to match host's Qt version
     DESCRIPTION     "A cross-platform USB Module for Qt."
     HOMEPAGE_URL    "https://github.com/fpoussin/QtUsb"
     LANGUAGES       CXX C
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index 1201d12..0000000
--- a/Jenkinsfile
+++ /dev/null
@@ -1,38 +0,0 @@
-pipeline {
-    agent { docker { image 'fpoussin/jenkins:ubuntu-20.04-qt5' } }
-
-    stages {
-        stage("Build and Test") {
-            stages {
-               stage("Build") {
-                   steps {
-                       sh '''
-                       mkdir build
-                       cd build
-                       qmake ..
-                       nice make -j $(nproc) all
-                       mkdir -p /tmp/qtusb
-                       make INSTALL_ROOT=/tmp/qtusb install
-                       cd ..
-                       '''
-                   }
-               }
-               stage("Test") {
-                   steps {
-                       sh '''
-                       cd build/tests
-                       make -i check TESTARGS="-o result.xml,xunitxml"
-                       cd $WORKSPACE
-                       ls -l build/tests/*/*/result.xml
-                       '''
-                   }
-               }
-            }
-        }
-    }
-    post {
-        always {
-            junit 'build/tests/*/*/result.xml'
-        }
-    }
-}
diff --git a/README.md b/README.md
index 9139851..36d3ecf 100755
--- a/README.md
+++ b/README.md
@@ -1,8 +1,7 @@
-# QtUsb [![GitHub version](https://badge.fury.io/gh/fpoussin%2Fqtusb.svg)](https://badge.fury.io/gh/fpoussin%2Fqtusb) [![Total alerts](https://img.shields.io/lgtm/alerts/g/fpoussin/QtUsb.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/fpoussin/QtUsb/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/fpoussin/QtUsb.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/fpoussin/QtUsb/context:cpp)
+# QtUsb [![GitHub version](https://badge.fury.io/gh/fpoussin%2Fqtusb.svg)](https://badge.fury.io/gh/fpoussin%2Fqtusb)  
 
-
-GCC: [![Build Status](https://jenkins.netyxia.net/buildStatus/icon?job=QtUsb%2Fmaster)](https://jenkins.netyxia.net/blue/organizations/jenkins/QtUsb/branches/)  
-MSVC: [![Build status](https://ci.appveyor.com/api/projects/status/4ns2jbdoveyj8n0y?svg=true)](https://ci.appveyor.com/project/fpoussin/qtusb)  
+GCC: ![Build Status]((https://github.com/fpoussin/QtUsb/actions/workflows/build.yml/badge.svg))](https://github.com/fpoussin/QtUsb/actions/)  
+MSVC: ![Build status](https://ci.appveyor.com/api/projects/status/4ns2jbdoveyj8n0y?svg=true)](https://ci.appveyor.com/project/fpoussin/qtusb)  
 
 A Cross-platform USB Module for Qt built around libusb-1.0 and libhidapi  
 Can be used as a library, or included directly into the project  
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index f131dec..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-branches:
-  only:
-    - master
-    - appveyor
-
-matrix:
-  fast_finish: false
-
-environment:
-  matrix:
-  - arch: x64
-    qt: 6.4
-    msvc: 2019
-    mode: dynamic
-    QTDIR: C:\Qt\%qt%\msvc2019_64
-    Qt6_DIR: C:\Qt\%qt%\msvc2019_64\lib\cmake
-    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
-
-  - arch: x64
-    qt: 6.4
-    msvc: 2019
-    mode: static
-    QTDIR: C:\Qt\%qt%\msvc2019_64
-    Qt6_DIR: C:\Qt\%qt%\msvc2019_64\lib\cmake
-    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
-
-  - arch: x86
-    qt: 6.4
-    msvc: 2019
-    mode: dynamic
-    QTDIR: C:\Qt\%qt%\msvc2019
-    Qt6_DIR: C:\Qt\%qt%\msvc2019_64\lib\cmake
-    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
-
-  - arch: x86
-    qt: 6.4
-    msvc: 2019
-    mode: static
-    QTDIR: C:\Qt\%qt%\msvc2019
-    Qt6_DIR: C:\Qt\%qt%\msvc2019_64\lib\cmake
-    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
-
-build_script:
-  - cd %APPVEYOR_BUILD_FOLDER%
-  - build_msvc.bat %msvc% %arch% %mode% %QTDIR% C:\projects\qtusb-build \projects\qtusb-install
-
-after_build:
-  - mkdir %APPVEYOR_BUILD_FOLDER%\artifacts
-  - cd %APPVEYOR_BUILD_FOLDER%\artifacts
-  - if %APPVEYOR_REPO_TAG%==true (
-      7z a %APPVEYOR_REPO_TAG_NAME%-qt%qt%-usb-msvc-%mode%-%arch%.7z C:\projects\qtusb-install\*
-    ) else (
-      7z a %APPVEYOR_REPO_COMMIT%-qt%qt%-usb-msvc-%mode%-%arch%.7z C:\projects\qtusb-install\*
-    )
-
-artifacts:
-  - path: artifacts\*.7z
-    name: QtUsb install files
-
-deploy:
-  - provider: GitHub
-    auth_token:
-      secure: FUMVTjWuerUmKlLiPtjpxjmizC+wsDanxGBFWF/T6sicn7ctP/Aleh9+hZKKskXJ
-    artifact: QtUsb install files
-    force_update: true
-    on:
-      branch: master
-      APPVEYOR_REPO_TAG: true
-
-test: off
-
-on_success:
-  - ps: |
-      $wc = New-Object 'System.Net.WebClient'
-      Get-ChildItem -Path C:\projects\qtusb-build\tests -Recurse -Filter "xunit.xml" | ForEach-Object { Write-Host $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", $_.FullName) }