From 896ca40562dd820ea588230070923b8000960dce Mon Sep 17 00:00:00 2001 From: parnic-sks <62021255+parnic-sks@users.noreply.github.com> Date: Tue, 15 Jun 2021 00:53:34 -0500 Subject: [PATCH] Convert from Travis CI to Github actions (#120) --- .github/workflows/release.yml | 122 ++++++++++++++++++++++++++++++++++ .travis.yml | 45 ------------- README.md | 6 +- build.sh | 0 4 files changed, 125 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml mode change 100644 => 100755 build.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3ad6cee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,122 @@ +name: Package and release +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + DEBIAN_RELEASE: buster + DOCKER_PWD: /root + DOCKER_IMAGE: debian:${DEBIAN_RELEASE} + GO_VERSION: 1.15.5 + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + os: [dragonfly, freebsd, linux, netbsd, openbsd] + arch: [amd64, arm, arm64, mips, mips64, mips64le, ppc64, ppc64le, s390x ] + exclude: + - os: dragonfly + arch: arm + - os: dragonfly + arch: arm64 + - os: dragonfly + arch: mips + - os: dragonfly + arch: mips64 + - os: dragonfly + arch: mips64le + - os: dragonfly + arch: ppc64 + - os: dragonfly + arch: ppc64le + - os: dragonfly + arch: s390x + - os: freebsd + arch: arm64 + - os: freebsd + arch: mips + - os: freebsd + arch: mips64 + - os: freebsd + arch: mips64le + - os: freebsd + arch: ppc64 + - os: freebsd + arch: ppc64le + - os: freebsd + arch: s390x + - os: netbsd + arch: arm64 + - os: netbsd + arch: mips + - os: netbsd + arch: mips64 + - os: netbsd + arch: mips64le + - os: netbsd + arch: ppc64 + - os: netbsd + arch: ppc64le + - os: netbsd + arch: s390x + - os: openbsd + arch: arm64 + - os: openbsd + arch: mips + - os: openbsd + arch: mips64 + - os: openbsd + arch: mips64le + - os: openbsd + arch: ppc64 + - os: openbsd + arch: ppc64le + - os: openbsd + arch: s390x + + steps: + - name: Clone repository + uses: actions/checkout@v2 + + - name: Set environment from runtime properties + run: echo "MATTERMOST_RELEASE=$(grep 'mattermost' dependabot/go.mod | cut -d' ' -f3)" >> $GITHUB_ENV + + - name: Pull docker image + run: 'docker pull "${{ env.DOCKER_IMAGE }}"' + + - name: Build + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + run: docker run --mount="type=bind,source=$PWD,destination=${{ env.DOCKER_PWD }}" --rm=true --tty=true --workdir="${{ env.DOCKER_PWD }}" -e DEBIAN_RELEASE -e MATTERMOST_RELEASE -e GOOS -e GOARCH "${{ env.DOCKER_IMAGE }}" ./build.sh + + - name: Tag release + if: github.ref == 'refs/heads/master' + uses: actions/github-script@v3 + # this throws an error if the tag already exists. can't find a way around that without writing our own Github REST client or forking github's scripts repo. + # would prefer to do this before any of these jobs run, but we need to know the mattermost version which only happens after a clone. could potentially + # setup a separate job which does clone + tag, but felt like this was "good enough" for now. + continue-on-error: true + with: + script: | + github.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ env.MATTERMOST_RELEASE }}', + sha: context.sha + }) + + - name: Create Github release + if: github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.MATTERMOST_RELEASE }} + files: | + mattermost-${{ env.MATTERMOST_RELEASE }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz + mattermost-${{ env.MATTERMOST_RELEASE }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz.sha512sum diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5d0994a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: c -os: linux -dist: bionic -services: - - docker -env: - global: - - DEBIAN_RELEASE='buster' - - DOCKER_PWD='/root' - - DOCKER_IMAGE="debian:${DEBIAN_RELEASE}" - - GO_VERSION='1.15.5' - matrix: - - GOOS='dragonfly' GOARCH='amd64' - - GOOS='freebsd' GOARCH='amd64' - - GOOS='freebsd' GOARCH='arm' - - GOOS='linux' GOARCH='arm' - - GOOS='linux' GOARCH='arm64' - - GOOS='linux' GOARCH='mips' - - GOOS='linux' GOARCH='mips64' - - GOOS='linux' GOARCH='mips64le' - - GOOS='linux' GOARCH='mipsle' - - GOOS='linux' GOARCH='ppc64' - - GOOS='linux' GOARCH='ppc64le' - - GOOS='linux' GOARCH='s390x' - - GOOS='netbsd' GOARCH='amd64' - - GOOS='netbsd' GOARCH='arm' - - GOOS='openbsd' GOARCH='amd64' - - GOOS='openbsd' GOARCH='arm' -before_install: - - export MATTERMOST_RELEASE="$(grep 'mattermost' dependabot/go.mod | cut -d' ' -f3)" - - docker pull "${DOCKER_IMAGE}" - - chmod +x build.sh -script: - - docker run --interactive=true --mount="type=bind,source=${PWD},destination=${DOCKER_PWD}" --rm=true --tty=true --workdir="${DOCKER_PWD}" -e DEBIAN_RELEASE -e MATTERMOST_RELEASE -e GOOS -e GOARCH "${DOCKER_IMAGE}" ./build.sh -before_deploy: - - git config --local user.name 'Travis CI' - - git config --local user.email 'travis@travis-ci.org' - - git tag "${MATTERMOST_RELEASE}" || true -deploy: - provider: releases - api_key: "${GITHUB_OAUTH_TOKEN}" - file: - - "${TRAVIS_BUILD_DIR}/mattermost-${MATTERMOST_RELEASE}-${GOOS}-${GOARCH}.tar.gz" - - "${TRAVIS_BUILD_DIR}/mattermost-${MATTERMOST_RELEASE}-${GOOS}-${GOARCH}.tar.gz.sha512sum" - skip_cleanup: true diff --git a/README.md b/README.md index 089734c..5c72c4f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # ubiquitous-memory: [Here be dragons][2] -[![Build Status](https://travis-ci.org/SmartHoneybee/ubiquitous-memory.svg?branch=master)](https://travis-ci.org/SmartHoneybee/ubiquitous-memory) +[![Build Status](https://github.com/SmartHoneybee/ubiquitous-memory/actions/workflows/release.yml/badge.svg)](https://github.com/SmartHoneybee/ubiquitous-memory/actions/workflows/release.yml) -[Travis CI][0] recipe that builds [Mattermost][1] for various operating systems and architectures. +[Github Actions][0] script that builds [Mattermost][1] for various operating systems and architectures. -[0]: https://travis-ci.org/SmartHoneybee/ubiquitous-memory +[0]: https://github.com/SmartHoneybee/ubiquitous-memory/actions [1]: https://mattermost.com/ [2]: https://en.wikipedia.org/wiki/Here_be_dragons diff --git a/build.sh b/build.sh old mode 100644 new mode 100755