Skip to content

Commit

Permalink
github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
coot committed Jun 12, 2020
1 parent ffdabf0 commit 9641334
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 17 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Haskell CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-haskell@v1
with:
ghc-version: '8.6.5'
cabal-version: '3.2'
- name: Cache
uses: actions/cache@v1
env:
cache-name: cache-cabal
with:
path: ~/.cabal
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup paths
run: echo "::add-path::${HOME}/.cabal/bin"
- name: Install dependencies
run: |
cabal update
cabal install purescript-0.13.8
cabal build --only-dependencies --enable-tests --enable-benchmarks
- name: Build
run: cabal build exe:zephyr
- name: Run tests
run: cabal run zephyr-test -- -m generators -m dceEval -m dceExpr -m TestLib
148 changes: 148 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Release workflow.
# It runs two jobs
# - build job which builds zephyr on: linux, macos and windows and uploads
# artifacts using `action/upload-artifact`.
# - release job which depends on completion of the previous job:
# * creata a new release using `actions/create-release`
# * downloads artifacts using `action/download-artifact`.
# * uploads artifacts to the release with `action/upload-release-asset`
# The last two actions are done for all three systems.
#
on:
push:
tags:
- 'v*'

name: Upload Release Assets

jobs:
build:
name: Release build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-haskell@v1
with:
ghc-version: '8.6.5'
cabal-version: '3.2'
- name: Setup paths
run: echo "::add-path::${HOME}/.cabal/bin"
- name: Build zephyr
run: bash bundle/build.sh ${{ runner.os }}
- name: Upload tar file
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}.tar.gz
path: bundle/${{ runner.os }}.tar.gz
- name: Upload sha file
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}.sha
path: bundle/${{ runner.os }}.sha

release:
needs: [build]
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

- name: Download Linux.tar.gz
uses: actions/download-artifact@v2
with:
name: Linux.tar.gz
- name: Download Linux.sha
uses: actions/download-artifact@v2
with:
name: Linux.sha
- name: Upload Linux.tar.gz
id: upload-Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Linux.tar.gz
asset_name: Linux.tar.gz
asset_content_type: application/zip
- name: Upload Linux.sha
id: upload-Linux-sha
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Linux.sha
asset_name: Linux.sha
asset_content_type: application/zip

- name: Download macOS.tar.gz
uses: actions/download-artifact@v2
with:
name: macOS.tar.gz
- name: Download macOS.sha
uses: actions/download-artifact@v2
with:
name: macOS.sha
- name: Upload macOS.tar.gz
id: upload-macOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: macOS.tar.gz
asset_name: macOS.tar.gz
asset_content_type: application/zip
- name: Upload macOS.sha
id: upload-macOS-sha
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: macOS.sha
asset_name: macOS.sha
asset_content_type: application/zip

- name: Download Windows.tar.gz
uses: actions/download-artifact@v2
with:
name: Windows.tar.gz
- name: Download Windows.sha
uses: actions/download-artifact@v2
with:
name: Windows.sha
- name: Upload Windows.tar.gz
id: upload-Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Windows.tar.gz
asset_name: Windows.tar.gz
asset_content_type: application/zip
- name: Upload Windows.sha
id: upload-Windows-sha
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: Windows.sha
asset_name: Windows.sha
asset_content_type: application/zip
24 changes: 7 additions & 17 deletions bundle/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@
## Usage bundle.sh os
set -e


if [[ -z ${1} ]]; then
echo "Usage build.sh os_name";
echo "Usage build.sh [Linux|macOS|Windows]";
exit 1;
fi

OS_NAME="$1"

# Build OS_NAME
case $1 in
"linux")
OS_NAME="x86_64-linux";;
"osx")
OS_NAME="x86_64-osx";;
"win64")
OS_NAME="x86_64-windows";;
*)
OS_NAME=${1};;
esac

if [[ "$OS" = "win64" ]]
if [[ "$OS" = "Windows" ]]
then
BIN_EXT=".exe"
else
Expand All @@ -31,11 +21,11 @@ fi

BUNDLE_DIR="bundle/zephyr"
mkdir -p ${BUNDLE_DIR}
cabal install --install-method=copy --installdir ${BUNDLE_DIR} exe:zephyr
ZEPHYR="${BUNDLE_DIR}/zephyr${BIN_EXT}"
cabal install --install-method=copy --installdir ${BUNDLE_DIR} exe:zephyr

# strip the executable
if [[ ${OS_NAME} != "x86_64-windows" ]]; then
if [[ ${OS_NAME} != "Windows" && -a ${ZEPHYR} ]]; then
strip ${ZEPHYR};
fi
cp README.md LICENSE ${BUNDLE_DIR};
Expand All @@ -44,7 +34,7 @@ cp README.md LICENSE ${BUNDLE_DIR};
cabal info . > "${BUNDLE_DIR}/info"

# Calculate the SHA hash
if [[ ${OS_NAME} = "x86_64-windows" ]]; then
if [[ ${OS_NAME} = "Windows" ]]; then
SHASUM="openssl dgst -sha1";
else
SHASUM="shasum";
Expand Down

0 comments on commit 9641334

Please sign in to comment.