Skip to content

Commit

Permalink
Add CI/CD (late, I know)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavSanchez committed May 31, 2021
1 parent ae1bd7f commit 63230b5
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
pull_request:
push:
branches: [master]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
stack-yaml:
- stack.yaml
fail-fast: false

steps:
- uses: actions/checkout@v2
- uses: freckle/stack-cache-action@main
with:
stack-yaml: ${{ matrix.stack-yaml }}
- uses: freckle/stack-action@main
with:
stack-yaml: ${{ matrix.stack-yaml }}
114 changes: 114 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
create_release:
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt

- name: Save Release URL File for Publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt

build_artifact:
needs: [create_release]
name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
ghc: ["8.10.4"]
cabal: ["3.4"]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set tag name
uses: olegtarasov/[email protected]
id: tag
with:
tagRegex: "v(.*)"
tagRegexGroup: 1

- name: Setup Haskell
uses: haskell/actions/setup@v1
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Freeze
run: |
cabal freeze
- name: Cache ~/.cabal/store
uses: actions/cache@v1
with:
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}

- name: Build binary
run: |
mkdir dist
cabal install exe:roadburn-redux-crawler --install-method=copy --overwrite-policy=always --installdir=dist
- if: matrix.os != 'windows-latest'
name: Set binary path name (non-Windows)
run: |
echo "BINARY_PATH=./dist/roadburn-redux-crawler${{ env.EXT }}" >> $GITHUB_ENV
- if: matrix.os == 'windows-latest'
name: Set binary path name and extension (Windows)
run: |
echo "EXT=.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "BINARY_PATH=./dist/roadburn-redux-crawler.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Compress binary
uses: svenstaro/[email protected]
with:
file: ${{ env.BINARY_PATH }}

- name: Load Release URL File from Release Job
uses: actions/download-artifact@v1
with:
name: release_url

- name: Get Release File Name and Upload URL
id: get_release_info
run: |
echo "::set-output name=upload_url::$(cat release_url/release_url.txt)"
- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.BINARY_PATH }}
asset_name: roadburn-redux-crawler-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}
asset_content_type: application/octet-stream

0 comments on commit 63230b5

Please sign in to comment.