Skip to content

Merge pull request #1 from jrl-umi3218/pre-commit-ci-update-config #9

Merge pull request #1 from jrl-umi3218/pre-commit-ci-update-config

Merge pull request #1 from jrl-umi3218/pre-commit-ci-update-config #9

Workflow file for this run

---
name: Package mc_panda_lirmm
on:
repository_dispatch:
types:
- package-master
- package-release
pull_request:
branches:
- "**"
push:
paths-ignore:
- README.md
- ".github/workflows/build.yml"
branches:
- "**"
tags:
- v*
jobs:
check-tag:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
if: startsWith(github.ref, 'refs/tags/')
- name: Check version coherency
run: |
set -x
export VERSION=`echo ${{ github.ref }} | sed -e 's@refs/tags/v@@'`
echo "REJECTION=PROJECT_VERSION in CMakeLists.txt does not match tag" >> $GITHUB_ENV
grep -q "project(mc_panda_lirmm .* VERSION ${VERSION}.*)" CMakeLists.txt
echo "REJECTION=Upstream version in debian/changelog does not match tag" >> $GITHUB_ENV
head -n 1 debian/changelog | grep -q "mc-panda (${VERSION}"
echo "REJECTION=" >> $GITHUB_ENV
export TAG=`echo ${{ github.ref }} | sed -e 's@refs/tags/@@'`
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
- name: Delete tag
run: |
set -x
curl --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X DELETE https://api.github.com/repos/${{ github.repository }}/git/${{ github.ref }}
if: failure()
- name: Notify tag deletion
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: "${{ secrets.SLACK_BOT_TOKEN }}"
slack-channel: "#ci"
slack-text: |
Tag *${{ github.ref }}* in *${{ github.repository }}* was deleted:
${{ env.REJECTION}}
if: failure()
- name: Create release
uses: jrl-umi3218/github-actions/create-release@master
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
tag: "${{ env.RELEASE_TAG }}"
if: startsWith(github.ref, 'refs/tags/')
build-packages:
needs: check-tag
strategy:
fail-fast: false
matrix:
dist:
- bionic
- focal
arch:
- amd64
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Choose extra mirror
run: |
# We upload in all conditions except when building on PR or branch other than master
export PACKAGE_UPLOAD=true
if ${{ startsWith(github.ref, 'refs/tags/') }}
then
export USE_HEAD=false
elif [ "${{ github.event.action }}" == "package-master" ]
then
export USE_HEAD=true
elif [ "${{ github.event.action }}" == "package-release" ]
then
export USE_HEAD=false
export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
git checkout $REF
git submodule sync && git submodule update
else
export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`
export USE_HEAD=true
if [ $REF != "master" ]
then
export PACKAGE_UPLOAD=false
fi
fi
if $USE_HEAD
then
echo "CLOUDSMITH_REPO=mc-rtc/head" >> $GITHUB_ENV
echo "PACKAGE_JOB=package-master" >> $GITHUB_ENV
else
echo "CLOUDSMITH_REPO=mc-rtc/stable" >> $GITHUB_ENV
echo "PACKAGE_JOB=package-release" >> $GITHUB_ENV
fi
echo "PACKAGE_UPLOAD=${PACKAGE_UPLOAD}" >> $GITHUB_ENV
- name: Setup ROS packages
run: |
set -x
export ROS_PYTHON=python2.7
export ROS_DISTRO=""
if [ "${{ matrix.dist }}" = "xenial" ]
then
export ROS_DISTRO="kinetic"
fi
if [ "${{ matrix.dist }}" = "bionic" ]
then
export ROS_DISTRO="melodic"
fi
if [ "${{ matrix.dist }}" = "focal" ]
then
export ROS_DISTRO="noetic"
export ROS_PYTHON=python3
export MC_LOG_UI_PYTHON_EXECUTABLE=python3
fi
echo "ROS_DISTRO=${ROS_DISTRO}" >> $GITHUB_ENV
sed -i -e"s/@ROS_DISTRO@/${ROS_DISTRO}/g" debian/control
cat debian/control
sed -i -e"s/@ROS_DISTRO@/${ROS_DISTRO}/g" debian/rules
sed -i -e"s/@ROS_PYTHON@/${ROS_PYTHON}/g" debian/rules
cat debian/rules
- name: Build package
uses: jrl-umi3218/github-actions/build-package-native@master
with:
dist: "${{ matrix.dist }}"
arch: "${{ matrix.arch }}"
ros-distro: "${{ env.ROS_DISTRO }}"
cloudsmith-repo: "${{ env.CLOUDSMITH_REPO }}"
- uses: actions/upload-artifact@v1
with:
name: packages-${{ matrix.dist }}-${{ matrix.arch }}
path: "/tmp/packages-${{ matrix.dist }}-${{ matrix.arch }}/"
if: env.PACKAGE_UPLOAD == 'true'
upload-packages:
needs: build-packages
strategy:
max-parallel: 1
fail-fast: false
matrix:
dist:
- bionic
- focal
arch:
- amd64
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Choose extra mirror
run: |
# We upload in all conditions except when building on PR or branch other than master
export PACKAGE_UPLOAD=true
if ${{ startsWith(github.ref, 'refs/tags/') }}
then
export USE_HEAD=false
elif [ "${{ github.event.action }}" == "package-master" ]
then
export USE_HEAD=true
elif [ "${{ github.event.action }}" == "package-release" ]
then
export USE_HEAD=false
export REF=`git tag --sort=committerdate --list 'v[0-9]*'|tail -1`
git checkout $REF
git submodule sync && git submodule update
else
export REF=`echo ${{ github.ref }} | sed -e 's@refs/[a-z]*/@@'`
export USE_HEAD=true
if [ $REF != "master" ]
then
export PACKAGE_UPLOAD=false
fi
fi
if $USE_HEAD
then
echo "CLOUDSMITH_REPO=mc-rtc/head" >> $GITHUB_ENV
echo "PACKAGE_JOB=package-master" >> $GITHUB_ENV
else
echo "CLOUDSMITH_REPO=mc-rtc/stable" >> $GITHUB_ENV
echo "PACKAGE_JOB=package-release" >> $GITHUB_ENV
fi
echo "PACKAGE_UPLOAD=${PACKAGE_UPLOAD}" >> $GITHUB_ENV
- name: Download packages
uses: actions/download-artifact@v1
with:
name: packages-${{ matrix.dist }}-${{ matrix.arch }}
if: env.PACKAGE_UPLOAD == 'true'
- name: Upload
uses: jrl-umi3218/github-actions/upload-package@master
with:
dist: ubuntu/${{ matrix.dist }}
repo: "${{ env.CLOUDSMITH_REPO }}"
path: packages-${{ matrix.dist }}-${{ matrix.arch }}
CLOUDSMITH_API_KEY: "${{ secrets.CLOUDSMITH_API_KEY }}"
if: env.PACKAGE_UPLOAD == 'true'