Skip to content

Commit

Permalink
Merge pull request #59 from sadraiiali/rcssmonitor-pipeline-appimage-…
Browse files Browse the repository at this point in the history
…pull

pipeline - automatic appimage and release creator
  • Loading branch information
hidehisaakiyama authored Jun 27, 2024
2 parents eecc372 + 54f8b7e commit ae7668a
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: ci

on:
push:
branches:
- "*"
tags:
- "*"


env:
release-prefix: "rcssmonitor-"


jobs:
app-image:
runs-on: ubuntu-latest
name: Build AppImage
steps:
- uses: actions/checkout@v4

- name: Create release folder
run: |
mkdir -p ${{ github.workspace }}/artifact
- name: Find CMakeLists.txt version
id: cmake_version
run: |
cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
echo "version=${cmake_version}" >> $GITHUB_OUTPUT
- name: Create builder-image
run: |
docker build -t builder-image:2004 -f ./utils/appimage/Dockerfile.builder-2004 .
# ------------------------------------------- Ubuntu 20.04 AppImage
- name: Build app image on 20.04
run: |
docker run --privileged --name builder-2004 builder-image:2004 /rcssmonitor/utils/appimage/docker-entrypoint.sh
docker cp builder-2004:/rcssmonitor/build/rcssmonitor-x86_64.AppImage \
${{ github.workspace }}/artifact/rcssmonitor-${{ steps.cmake_version.outputs.version }}-x86_64.AppImage
# ------------------------------------------- Artifact
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: rcssmonitor-x86_64
path: ${{ github.workspace }}/artifact/*
retention-days: 5

- name: Check if there is no release with the same tag
id: check_release
run: |
out=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.cmake_version.outputs.version }})
echo "release_exists=${out}" >> $GITHUB_OUTPUT
- name: Create release note
if : ${{ steps.check_release.outputs.release_exists == '404' }}
run: |
export GITHUB_REPOSITORY=${{ github.repository }}
python utils/appimage/create_release_note.py
cp release_note.md ${{ github.workspace }}/artifact/release_note
# ------------------------------------------- Release
- name: Create Release
if: ${{ steps.check_release.outputs.release_exists == '404' }}
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: "${{ github.workspace }}/artifact/rcssmonitor-${{ steps.cmake_version.outputs.version }}-x86_64.AppImage"
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: "${{ github.workspace }}/artifact/release_note"
name: "${{ env.release-prefix }}${{ steps.cmake_version.outputs.version }}"
tag: ${{ steps.cmake_version.outputs.version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.o
build/
35 changes: 35 additions & 0 deletions utils/appimage/Dockerfile.builder-2004
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ubuntu:20.04

RUN apt-get clean && apt-get update --allow-insecure-repositories && \
DEBIAN_FRONTEND="noninteractive" apt-get -y install \
tzdata \
gcc \
g++ \
wget \
libfl-dev \
flex \
bison \
libboost-all-dev \
automake \
make \
cmake \
iputils-ping \
build-essential \
libtool \
fuse \
tree \
libfuse-dev \
zlib1g-dev \
qt5-default \
libfontconfig1-dev \
libaudio-dev \
libxt-dev \
libglib2.0-dev \
libxi-dev \
libxrender-dev

WORKDIR /rcssmonitor

COPY . /rcssmonitor


35 changes: 35 additions & 0 deletions utils/appimage/build_appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e


SCRIPT_DIR="$(pwd)/build"
M_BUILD_PWD="$SCRIPT_DIR/monitor-bin"
BIN_PATH="$M_BUILD_PWD/bin/rcssmonitor"
APP_IMAGE_DIR="$SCRIPT_DIR/appimage"

cd $SCRIPT_DIR

wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" -O linuxdeploy-x86_64.AppImage
wget -c "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" -O linuxdeploy-plugin-qt-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-plugin-qt-x86_64.AppImage


rm -rf $APP_IMAGE_DIR || true
mkdir -p $APP_IMAGE_DIR || true



# ------ LIBRARIES
LIBZ_PATH=$(ldd $BIN_PATH | grep libz.so | awk '{ print $3 }')
LIBRCSSRCG_PATH=$(ldd $BIN_PATH | grep librcssrcg.so | awk '{ print $3 }')

./linuxdeploy-x86_64.AppImage --appdir $APP_IMAGE_DIR \
--plugin qt \
-l $LIBZ_PATH \
-l $LIBRCSSRCG_PATH \
--executable $M_BUILD_PWD/bin/rcssmonitor \
--desktop-file $SCRIPT_DIR/rcssmonitor.desktop \
--icon-file $SCRIPT_DIR/rcssmonitor.png \
--output appimage

15 changes: 15 additions & 0 deletions utils/appimage/build_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

WORKDIR="$(pwd)"

BUILD_PWD="$WORKDIR/build"
MONITOR_BIN_PATH="$BUILD_PWD/monitor-bin"
mkdir -p $MONITOR_BIN_PATH
autoreconf -i
automake --add-missing
$WORKDIR/configure --prefix="$MONITOR_BIN_PATH"
make -j$(nproc)
make install
cp $WORKDIR/utils/appimage/rcssmonitor.desktop $BUILD_PWD
cp $WORKDIR/utils/appimage/rcssmonitor.png $BUILD_PWD
89 changes: 89 additions & 0 deletions utils/appimage/create_release_note.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#/bin/python

import os
from urllib.request import urlopen
import json


repo = os.environ.get("GITHUB_REPOSITORY")


def create_release_note():
release_notes = {}
latest_version = ""
with open("NEWS") as f:
for line in f:
if line.startswith("["):
version = line.strip()
version = version.replace("[", "")
version = version.replace("]", "")
version = version.strip()
release_notes[version] = ""
latest_version = version
else:
release_notes[latest_version]+= line.strip() + "\n"

return release_notes

def read_latest_release():
url = f"https://api.github.com/repos/{repo}/releases"
print(url)
response = urlopen(url)
data = response.read()
last_release = json.loads(data)[0]
return last_release

def current_version():
cmake_file = ""
with open("CMakeLists.txt") as f:
cmake_file = f.read()
version = ""
#project(rcssmonitor VERSION
cmake_file = cmake_file.split("project(rcssmonitor VERSION")[1]
version = cmake_file.split(")")[0]
version = version.strip()
return version

def compare_version(version1, version2):
version1 = version1.split(".")
version2 = version2.split(".")
for i in range(0, len(version1)):
if int(version1[i]) > int(version2[i]):
return 1
elif int(version1[i]) < int(version2[i]):
return -1
return 0
def release_note_until_last_release(release_notes, last_release):
out = ""
for key in release_notes:
if compare_version(key, last_release) > 0:
out+= f"[{key}]\n"
out += release_notes[key]
out += "\n\n"
elif compare_version(key, last_release) == 0:
break
return out

def get_release_from_github(latest_release):
out = latest_release["tag_name"]
out = out.replace("rcssmonitor-", "")
return out


def main():

release_notes = create_release_note()
last_release_org = read_latest_release()
last_release = get_release_from_github(last_release_org)
curr_version = current_version()
print(f"Current version: {curr_version}")
print(f"Action release: {last_release}")
release = release_note_until_last_release(release_notes, last_release)
with open("release_note.md", "w") as f:
if release == "":
f.write("TBD")
return
f.write(release)

if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions utils/appimage/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e

cd /rcssmonitor

bash /rcssmonitor/utils/appimage/build_code.sh
bash /rcssmonitor/utils/appimage/build_appimage.sh
14 changes: 14 additions & 0 deletions utils/appimage/rcssmonitor.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=rcssmonitor
Comment=Robocup 2D Soccer Simulation Monitor
TryExec=rcssmonitor
Exec=rcssmonitor
Icon=rcssmonitor
MimeType=image/x-foo;
Categories=Development;
X-KDE-Library=librcssmonitor
X-KDE-FactoryName=rcssmonitorfactory
X-KDE-ServiceType=rcssmonitorService

Binary file added utils/appimage/rcssmonitor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ae7668a

Please sign in to comment.