Skip to content

Commit

Permalink
👷 add Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
parry84 committed Mar 18, 2021
1 parent 50902fe commit fad5d3a
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
create_release:
name: Create Github Release
runs-on: ubuntu-latest
steps:
- name: Check out 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/[email protected]
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]
ghc:
- "8.8.4"
- "8.10.3"
cabal: ["3.2"]
exclude:
- os: windows-latest
ghc: 8.8.4

steps:
- name: Check out 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/[email protected]
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

- name: Freeze
run: |
cabal freeze
- name: Cache ~/.cabal/store
uses: actions/[email protected]
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:prom-docs --install-method=copy --overwrite-policy=always --installdir=dist
- if: matrix.os == 'windows-latest'
name: Set extension to .exe on Windows
run: echo "EXT=.exe" >> $GITHUB_ENV

- name: Set binary path name
run: echo "BINARY_PATH=./dist/prom-docs${{ env.EXT }}" >> $GITHUB_ENV

- name: Compress binary
uses: svenstaro/[email protected]
with:
file: ${{ env.BINARY_PATH }}

- name: Load Release URL File from release job
uses: actions/[email protected]
with:
name: release_url
path: release_url

- name: Get Release File Name & 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: prom-docs-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}
asset_content_type: application/octet-stream

0 comments on commit fad5d3a

Please sign in to comment.