ci/cd: add github workflows

All the builds are done in fedora containers at the moment.

1. build.yml - triggers on every push and PR, it just builds the
   project
2. build-cmake.yml - triggers on every push and PR, it builds the
   project with cmake
3. release.yml - triggers on v* tags on master, it creates a new github
   release, builds a fedora RPM and also uploads the rpm and src rpm to
   the release page for distribution

minor bug in the makefile was fixed, it was preventing from using
multiple threads for compilation which slowed down the build
This commit is contained in:
Alex Diaz 2021-10-19 19:50:15 -04:00
parent 8066172567
commit fff4daea8f
No known key found for this signature in database
GPG key ID: 5F95650F793D0948
4 changed files with 104 additions and 1 deletions

21
.github/workflows/build-cmake.yml vendored Normal file
View file

@ -0,0 +1,21 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
fedora-cmake-build:
runs-on: ubuntu-latest
container: fedora:34
steps:
- uses: actions/checkout@v2
- name: install tools and dependencies
run: |
dnf install -y cmake rpm-build findutils clang-tools-extra 'dnf-command(builddep)'
dnf builddep -y mouse_m908.spec
- name: build mouse_m908 with cmake
run: |
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Bbuild
cmake --build build

20
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,20 @@
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
fedora-rpm-build:
runs-on: ubuntu-latest
container: fedora:34
steps:
- uses: actions/checkout@v2
- name: install tools and dependencies
run: |
dnf install -y rpm-build findutils clang-tools-extra 'dnf-command(builddep)'
dnf builddep -y mouse_m908.spec
- name: build mouse_m908 rpm package
run: |
make -j4 rpm

62
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,62 @@
on:
push:
tags:
- v*
jobs:
fedora-release-rpm:
runs-on: ubuntu-latest
container: fedora:34
steps:
- name: get version from tag
run: |
echo "RELEASE_VER=${GITHUB_REF#*/*/v}" >> ${GITHUB_ENV}
- uses: actions/checkout@v2
- name: install tools and dependencies
run: |
dnf install -y rpm-build findutils clang-tools-extra 'dnf-command(builddep)'
dnf builddep -y mouse_m908.spec
- name: build mouse_m908 rpm package
run: |
make -j4 rpm
make -j4 src-rpm
- name: upload rpm package artifact
uses: actions/upload-artifact@v2
with:
name: mouse_m908-${{ github.run_id }}-1.x86_64.rpm
path: mouse_m908-${{ env.RELEASE_VER }}-1.x86_64.rpm
- name: upload src rpm package artifact
uses: actions/upload-artifact@v2
with:
name: mouse_m908-${{ github.run_id }}.src.rpm
path: mouse_m908-${{ env.RELEASE_VER }}-1.src.rpm
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: upload rpm package to release page
id: upload-release-rpm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mouse_m908-${{ env.RELEASE_VER }}-1.x86_64.rpm
asset_name: mouse_m908-${{ env.RELEASE_VER }}-1.x86_64.rpm
asset_content_type: application/octet-stream
- name: upload src rpm package to release page
id: upload-release-srpm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mouse_m908-${{ env.RELEASE_VER }}-1.src.rpm
asset_name: mouse_m908-${{ env.RELEASE_VER }}-1.src.rpm
asset_content_type: application/octet-stream

View file

@ -52,7 +52,7 @@ upgrade: install
# this builds a .rpm for Fedora/RHEL systems # this builds a .rpm for Fedora/RHEL systems
rpm: rpm:
rpmbuild --buildroot $(PWD)/rpmbuild/BUILDROOT --define "_topdir $(PWD)/rpmbuild" -bb mouse_m908.spec +rpmbuild --buildroot $(PWD)/rpmbuild/BUILDROOT --define "_topdir $(PWD)/rpmbuild" -bb mouse_m908.spec
# this builds .src.rpm for Fedora/RHEL systems # this builds .src.rpm for Fedora/RHEL systems
src-rpm: src-rpm: