From 007a2bc83568f4429fe727e5b435ed08f105fa07 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 23 Feb 2021 21:02:26 +0100 Subject: [PATCH] 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. --- .github/workflows/build.yml | 95 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 61 ++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8fa7569 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..37f578e --- /dev/null +++ b/.github/workflows/release.yml @@ -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