Skip to content

Commit

Permalink
github.workflow: Adds continuous and release GitHub workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Paleologue committed Sep 8, 2021
1 parent 314a3a2 commit 4a67067
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Test

on:
push:
branches: [ master, release-2.9, team/platform/dev ]
pull_request:
branches: [ master, release-2.9, team/platform/dev ]

env:
FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04

steps:

- name: Install Build Tools
run: pip install qibuild

- name: Install Dependencies
# TODO move these dependencies in the toolchain
run: sudo apt install libgtest-dev libgmock-dev

- uses: actions/checkout@v2

- name: Prepare QiBuild Toolchain
run: qitoolchain create qisdk $FEED

- name: Prepare QiBuild Config
run: |
qibuild init
qibuild add-config qisdk -t qisdk
- name: Configure
run: qibuild configure -c qisdk --debug -DQI_WITH_TESTS=ON -DCMAKE_CXX_FLAGS=-pthread

- name: Build
run: qibuild make -c qisdk

- name: Test
run: qitest run -c qisdk
26 changes: 26 additions & 0 deletions .github/workflows/make_feed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Retrieves the latest release output to generate a QiToolchain XML feed.
set -e
echo "Getting packages from current release at ${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest"
ASSETS_URL=$(curl --silent "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/latest" |
jq -r '.assets_url')
PACKAGES_URLS=$(curl --silent ${ASSETS_URL} |
jq '.[] | .browser_download_url' |
grep .zip | xargs -L 1 echo) # echo removes the extra quotes

echo "Making a toolchain referencing the following packages: ${PACKAGES_URLS}"
echo "<toolchain>" > feed.xml
for URL in $PACKAGES_URLS; do
ZIP=package.zip
wget -q $URL -O $ZIP;
NAME=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@name)" -)
VERSION=$(unzip -p $ZIP package.xml | xmllint --xpath "string(/package/@version)" -)
echo " <package name=\"${NAME}\" version=\"${VERSION}\" url=\"${URL}\" />" >> feed.xml
rm $ZIP
done

echo "Adding sub-toolchain from ${FEED}"
echo " <feed url=\"${FEED}\" />" >> feed.xml
echo "</toolchain>" >> feed.xml

realpath feed.xml
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release with Toolchain

on:
push:
tags: "v*"

env:
FEED: https://github.com/victorpaleologue/libqi/releases/download/v1.8.8-actions/feed.xml

jobs:
gh_tagged_release:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04

steps:

- name: Install Utilities
run: sudo apt install apt-utils ca-certificates locales curl wget jq libxml2-utils xmlstarlet

- name: Install Build Tools
run: pip install qibuild

- name: Install Dependencies
# TODO move these dependencies in the toolchain
run: sudo apt install libgtest-dev libgmock-dev

- uses: actions/checkout@v2

- name: Prepare QiBuild Toolchain
run: qitoolchain create qisdk $FEED

- name: Prepare QiBuild Config
run: |
qibuild init
qibuild add-config qisdk -t qisdk
- name: Set Version
run: xmlstarlet ed --inplace -i '/project/qibuild' -t attr -n version -v `git describe --tags` qiproject.xml

- name: Build QiToolchain Package # Outputs the package as a .zip in ./package/
run: qibuild package -c qisdk --release -DQI_WITH_TESTS=OFF -DCMAKE_CXX_FLAGS=-pthread

- name: Release Package
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
package/*.zip
id: "release"

- name: Make Feed # Outputs feed.xml
run: .github/workflows/make_feed.sh

- name: Release Feed
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: feed.xml
asset_name: feed.xml
asset_content_type: application/xml

0 comments on commit 4a67067

Please sign in to comment.