diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0495c860..5d164960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,17 @@ name: CI -on: [push, pull_request] +on: + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + paths-ignore: [ '**.md', '**.adoc' ] + pull_request: + branches: [ '**' ] + paths-ignore: [ '**.md', '**.adoc' ] + jobs: build: - runs-on: [ "ubuntu-latest" ] + if: contains(github.event.head_commit.message, 'deploy+') == false + runs-on: "ubuntu-latest" strategy: matrix: env: @@ -10,9 +19,9 @@ jobs: - { CXX: clang++, CC: clang, CXX_FOR_BUILD: clang++, CC_FOR_BUILD: clang } steps: - name: checkout-source - uses: actions/checkout@v2 - - name: checkout-submodules - run: git submodule update --init --recursive + uses: actions/checkout@v1 + with: + submodules: recursive - name: update-system run: sudo apt-get update -qq - name: install-deps @@ -24,3 +33,4 @@ jobs: cd build cmake .. make + diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..d620c010 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,97 @@ +name: DEPLOY + +on: + push: + branches: [ '**' ] + tags-ignore: [ '**' ] + +jobs: + + build: + if: contains(github.event.head_commit.message, 'deploy+') + strategy: + matrix: + container: [ "ubuntu:18.04", "ubuntu:19.10", "ubuntu:20.04", "debian:9", "debian:10", "fedora:29", "fedora:30", "fedora:31", "fedora:32", "archlinux:latest" ] + # this list should be updated from time to time by consulting these pages: + # https://releases.ubuntu.com/ + # https://wiki.debian.org/DebianReleases#Production_Releases + # https://fedoraproject.org/wiki/Releases + runs-on: "ubuntu-latest" + container: + image: ${{ matrix.container }} + env: + DIST: ${{ matrix.container }} + DEBIAN_FRONTEND: noninteractive + steps: + - name: checkout-source + uses: actions/checkout@v1 + with: + submodules: recursive + - name: run-builder + shell: bash + run: ./tools/build.sh + - name: upload-artifacts + uses: actions/upload-artifact@v1 + with: + name: package-archives + path: artifact + + deploy: + needs: build + runs-on: "ubuntu-latest" + container: + image: "archlinux:latest" + env: + BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + BINTRAY_APIKEY: ${{ secrets.BINTRAY_APIKEY }} + BINTRAY_GPG_DATA: ${{ secrets.GPG_DATA }} + BINTRAY_GPG_ID: ${{ secrets.GPG_ID }} + JFROG_CLI_OFFER_CONFIG: false + steps: + - name: checkout-source + uses: actions/checkout@v1 + with: + submodules: recursive + - name: install-jfrog-cli + uses: jfrog/setup-jfrog-cli@v1 + - name: download-artifacts + uses: actions/download-artifact@v1 + with: + name: package-archives + path: artifact + - name: bintray-publish + shell: bash + run: ./tools/publish.sh + + release: + needs: deploy + runs-on: "ubuntu-latest" + steps: + - name: checkout-source + uses: actions/checkout@v1 + - name: get-version + id: get_version + shell: bash + run: | + RELEASE_VERSION=$(cat version.txt | head -n1) + echo ::set-output name=RELEASE_VERSION::$RELEASE_VERSION + - name: download-artifacts + uses: actions/download-artifact@v1 + with: + name: package-archives + path: artifact + - name: create-release + id: create_release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.get_version.outputs.RELEASE_VERSION }} + name: ${{ steps.get_version.outputs.RELEASE_VERSION }} + artifacts: "artifact/*" + allowUpdates: true + draft: true + body: | + [![Github Releases (by Release)](https://img.shields.io/github/downloads/${{ github.repository }}/${{ steps.get_version.outputs.RELEASE_VERSION }}/total.svg)]() + ### Changes in this release: + - ... + diff --git a/CMakeLists.txt b/CMakeLists.txt index d23b7697..8850bc3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.0.2) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -project(OpenBangla-Keyboard VERSION 2.0.0) +file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" VERSION_STRING LIMIT_COUNT 1 REGEX "^.+") +project("OpenBangla-Keyboard" VERSION ${VERSION_STRING}) set(APP_NAME "OpenBangla-Keyboard") ## Set versions @@ -75,8 +76,8 @@ endif () set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenSource Bengali input method") -set(CPACK_PACKAGE_VENDOR "Muhammad Mominul Huque") -set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Muhammad Mominul Huque ") +set(CPACK_PACKAGE_VENDOR "OpenBangla Team") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "OpenBangla Team ") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/data/Readme.txt") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") @@ -84,12 +85,12 @@ set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}-$ENV{DIST}") set(CPACK_STRIP_FILES TRUE) -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://openbangla.github.io/") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://openbangla.github.io/") set(CPACK_DEBIAN_PACKAGE_SECTION "utils") set(CPACK_DEBIAN_PACKAGE_DEPENDS "ibus (>= 1.5.1)") set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_RPM_PACKAGE_LICENSE "GPLv3") -set(CPACK_RPM_PACKAGE_URL "http://openbangla.github.io/") +set(CPACK_RPM_PACKAGE_URL "https://openbangla.github.io/") set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.9.0, ibus >= 1.5.1, ibus-libs >= 1.5.1") set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) # Prevents CPack from generating file conflicts diff --git a/src/engine/riti b/src/engine/riti index b1b94470..f3b53dd3 160000 --- a/src/engine/riti +++ b/src/engine/riti @@ -1 +1 @@ -Subproject commit b1b94470aee8b8ed78268b2a4896f7a71a02ca89 +Subproject commit f3b53dd3881aa237c80941854ce03e66af9346a5 diff --git a/tools/LICENSE b/tools/LICENSE new file mode 100644 index 00000000..81c823e9 --- /dev/null +++ b/tools/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 OpenBangla + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tools/PKGBUILD.stub b/tools/PKGBUILD.stub new file mode 100644 index 00000000..7483b7ee --- /dev/null +++ b/tools/PKGBUILD.stub @@ -0,0 +1,20 @@ +# Maintainer: OpenBangla Team +# THIS IS A *PARTIAL* PKGBUILD TEMPLATE FOR CUSTOM AUTOBUILD PROCESS ONLY +pkgname="openbangla-keyboard" +pkgrel=1 +pkgdesc="An OpenSource, Unicode compliant Bengali Input Method" +arch=('x86_64') +url="https://openbangla.github.io" +license=('GPL3') +depends=('ibus' 'qt5-base') +build() { + cd "$srcdir" + mkdir build && cd build + cmake .. + make +} +package() { + cd "$srcdir" + make -C build DESTDIR="$pkgdir" install +} + diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 00000000..a9d7cbb6 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,7 @@ +# buildman + +Builds OpenBangla Keyboard packages for various distributions. + +- A lightweight C/I workflow runs by default on each commit. +- if commit message has the string `deploy+`, then a deploy workflow runs instead of the default one. + - if build passes, this workflow will deploy packages to repositories, and create a github release. diff --git a/tools/build.sh b/tools/build.sh new file mode 100755 index 00000000..ee4c8727 --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,64 @@ +#! /bin/bash +RELEASE_VERSION=$(cat version.txt | head -n1) +# follow cmake PACKAGE_FILE_NAME directive in main repo +RELEASE_STUB="OpenBangla-Keyboard_${RELEASE_VERSION}-" + +makeDeb () { + RELEASE_FILENAME="${RELEASE_STUB}${DIST}.deb" + apt-get -y install build-essential cmake libibus-1.0-dev qt5-default rustc cargo ninja-build curl + cmake -H"$GITHUB_WORKSPACE" -B/build -GNinja -DCPACK_GENERATOR=DEB + ninja package -C /build + RELEASE_FILE="/build/${RELEASE_FILENAME}" +} + +makeRpm () { + RELEASE_FILENAME="${RELEASE_STUB}${DIST}.rpm" + dnf install -y --allowerasing @buildsys-build cmake ibus-devel qt5-qtdeclarative-devel rust cargo ninja-build + cmake -H"$GITHUB_WORKSPACE" -B/build -GNinja -DCPACK_GENERATOR=RPM + ninja package -C /build + RELEASE_FILE="/build/${RELEASE_FILENAME}" +} + +makeArch () { + DIST=archlinux + echo "PACKAGER='OpenBangla Team '" >> /etc/makepkg.conf + PKGEXT=".pkg.tar.zst" + echo "PKGEXT='$PKGEXT'" >> /etc/makepkg.conf + RELEASE_FILENAME="${RELEASE_STUB}${DIST}${PKGEXT}" + pacman -S --noconfirm --needed base-devel cmake libibus qt5-base rust curl + mkdir /build + cd /build + cp -fpr "$GITHUB_WORKSPACE" /build/src + cp "${GITHUB_WORKSPACE}/tools/PKGBUILD.stub" /build/PKGBUILD + sed -i "/pkgname=/a pkgver=\"${RELEASE_VERSION}\"" /build/PKGBUILD + useradd -m builder + chown -R builder:builder /build + sudo -u builder makepkg -fd --skipinteg + mv openbangla-keyboard-*${PKGEXT} ${RELEASE_FILENAME} + RELEASE_FILE=$(realpath "${RELEASE_FILENAME}") +} + +if [[ $DIST =~ ^(ubuntu|debian) ]]; then + apt-get -qq update + apt-get -y install git + # this is to read distro codename from filename during deployment + CODENAME=$(cat /etc/os-release | grep "VERSION_CODENAME" | cut -d= -f2) + DIST="${DIST}-${CODENAME}" + BUILDFUNC=makeDeb +elif [[ $DIST =~ ^fedora ]]; then + dnf -y --allowerasing distro-sync + dnf -y install git + BUILDFUNC=makeRpm +elif [[ $DIST =~ ^archlinux ]]; then + pacman -Syyu --noconfirm --needed + pacman -S --noconfirm --needed base git + BUILDFUNC=makeArch +fi + +DIST=${DIST/:/} +${BUILDFUNC} + +DEPLOY_PATH="${GITHUB_WORKSPACE}/artifact" +mkdir "$DEPLOY_PATH" +mv "$RELEASE_FILE" "${DEPLOY_PATH}/" + diff --git a/tools/publish.sh b/tools/publish.sh new file mode 100755 index 00000000..0c7113e8 --- /dev/null +++ b/tools/publish.sh @@ -0,0 +1,92 @@ +#!/bin/bash +ORG='openbangla' +PACKAGE='openbangla-keyboard' +DISTLIST=(ubuntu debian fedora archlinux) +RELEASE_VERSION=$(cat version.txt | head -n1) +jfrog bt config --user "$BINTRAY_USER" --key "$BINTRAY_APIKEY" --licenses 'GPL-3.0' +pacman -Syyuu --noconfirm --needed jq rpm +cd artifact + +gpgImport () { + echo -e "-----BEGIN PGP PRIVATE KEY BLOCK-----\n\n${BINTRAY_GPG_DATA}\n-----END PGP PRIVATE KEY BLOCK-----" \ + | gpg --import 2> /dev/null +} + +pubDeb () { + # prepare an ordered list of ubuntu release {version:codename} dict + curl https://api.launchpad.net/devel/ubuntu/series \ + | jq -M '.entries|sort_by(.version|tonumber)|map({(.version): .name})' \ + | sed -r 's/[][ ,"\{\}]//g' \ + | grep -v '^\s*$' \ + > dists.txt + for PKG in $(ls ./*${REPO}* 2>/dev/null); do + # read distro code from filename + CODENAME=$(echo "$PKG" | grep -oP '[^-]+.deb$' | cut -d. -f1) + jfrog bt upload --publish --override --deb "${CODENAME}/main/amd64" "$PKG" "$VERSION_PATH" + if [ $REPO == ubuntu ]; then + # we only build for major/first yearly releases. + # this block uploads the package for the other version in the same range + VERSION_STR=$(grep "$CODENAME" dists.txt) + VERSION_MAJOR=$(echo "$VERSION_STR" | cut -d. -f1) + OTHER_VERSION_STR=$(grep "^${VERSION_MAJOR}\." dists.txt | grep -v "$CODENAME") + if [ -n "$OTHER_VERSION_STR" ]; then + OTHER_CODENAME=$(echo "$OTHER_VERSION_STR" | cut -d: -f2) + OTHER_VERSION_STR=${OTHER_VERSION_STR/:/-} + VERSION_STR=${VERSION_STR/:/-} + ln -frs "$PKG" "${PKG/$VERSION_STR/$OTHER_VERSION_STR}" + jfrog bt upload --publish --override --deb "${OTHER_CODENAME}/main/amd64" ./*${OTHER_CODENAME}.deb "$VERSION_PATH" + fi + fi + done +} + +pubRpm () { + gpgImport + ARCH='x86_64' + gpg --export -a "${BINTRAY_GPG_ID}" > pubkey.asc + rpm --import pubkey.asc + rm pubkey.asc + echo "%_signature gpg" > "${HOME}/.rpmmacros" + echo "%_gpg_name ${BINTRAY_GPG_ID}" >> "${HOME}/.rpmmacros" + for PKG in $(ls ./*${REPO}* 2>/dev/null); do + rpm --addsign "$PKG" + VERSION_ID=$(echo "$PKG" | grep -oP '[\d]+.rpm$' | cut -d. -f1) + jfrog bt upload --publish --override "$PKG" "$VERSION_PATH" "${VERSION_ID}/${ARCH}/" + done +} + +pubArch () { + gpgImport + ARCH='x86_64' + # only one file should be listed anyway + for PKG in $(ls -1 ./*${REPO}* 2>/dev/null); do + # get repo metadata from the "meta" version, creating it if necessary + [[ $(jfrog bt version-show "${PACKAGE_PATH}/meta" 2> /dev/null) ]] \ + || jfrog bt version-create --vcs-tag "0.0.0" --desc "archlinux repo metadata" "${PACKAGE_PATH}/meta" + jfrog bt download-ver "${PACKAGE_PATH}/meta" + if [ -d "$ARCH" ]; then + mv "$ARCH" meta + fi + mkdir -p meta + gpg --detach-sign --no-armor -u "$BINTRAY_GPG_ID" "$PKG" + repo-add -p -s -k "$BINTRAY_GPG_ID" "meta/${ORG}.db.tar.gz" "$PKG" + jfrog bt upload --publish --override "meta/*" "${PACKAGE_PATH}/meta" "${ARCH}/" + jfrog bt upload --publish --override "${PKG}*" "${VERSION_PATH}" "${ARCH}/" + done +} + +for REPO in ${DISTLIST[*]}; do + PACKAGE_PATH="${ORG}/${REPO}/${PACKAGE}" + VERSION_PATH="${PACKAGE_PATH}/${RELEASE_VERSION}" + # create version + [[ $(jfrog bt version-show "$VERSION_PATH" 2>/dev/null) ]] && op=version-update || op=version-create + jfrog bt $op --vcs-tag "$RELEASE_VERSION" --released "$(date +'%Y-%m-%dT%H:%M:%S.000Z')" "$VERSION_PATH" + # upload files + if [[ $REPO =~ ubuntu|debian ]]; then + pubDeb + elif [ $REPO == fedora ]; then + pubRpm + elif [ $REPO == archlinux ]; then + pubArch + fi +done diff --git a/version.txt b/version.txt new file mode 100755 index 00000000..227cea21 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +2.0.0