Add Github Actions CI builds and releases

The new Github Actions offers similar functionality as the Travis CI
integration, but with some interesting extra features:

The build action is almost equivalent to the existing Travis build
configuration. But as an extra feature, the build artifacts are now
available for download.

The release action does automatically build a distribution tarball and
create a Github release, whenever a new version is tagged and pushed.
This commit is contained in:
Jef Driesen 2021-02-23 21:02:26 +01:00
parent 6b576da5ef
commit 007a2bc835
2 changed files with 156 additions and 0 deletions

95
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,95 @@
name: Build
on: [push, pull_request]
jobs:
linux:
name: Linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
- run: autoreconf --install --force
- run: ./configure --prefix=/usr
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v2
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
mac:
name: Mac
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: brew install autoconf automake libtool hidapi libusb
- run: autoreconf --install --force
- run: ./configure --prefix=/usr
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v2
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
windows:
name: Windows
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [i686, x86_64]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
- run: autoreconf --install --force
- run: ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v2
with:
name: ${{ github.job }}-${{ matrix.arch }}
path: ${{ github.job }}-${{ matrix.arch }}.tar.gz

61
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: Release
on:
push:
tags: 'v*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Version number
id: version
run: |
VERSION="${GITHUB_REF/refs\/tags\/v/}"
if [ "${VERSION}" = "${VERSION%%-*}" ]; then
PRERELEASE=false
else
PRERELEASE=true
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=prerelease::${PRERELEASE}
- name: Build distribution tarball
id: build
run: |
sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
autoreconf --install --force
./configure
make
make distcheck
- name: Check tarball version number
id: check
run: |
FILENAME="libdivecomputer-${{ steps.version.outputs.version }}.tar.gz"
if [ ! -f "${FILENAME}" ]; then
echo ::error ::Tarball \'${FILENAME}\' not found!
exit 1
fi
- uses: actions/create-release@v1
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
prerelease: ${{ steps.version.outputs.prerelease }}
- uses: actions/upload-release-asset@v1
id: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: libdivecomputer-${{ steps.version.outputs.version }}.tar.gz
asset_name: libdivecomputer-${{ steps.version.outputs.version }}.tar.gz
asset_content_type: application/gzip