Skip to content

Commit

Permalink
[#337] Implement binary releases on CI (#345)
Browse files Browse the repository at this point in the history
* [#337] Implement binary releases on CI

Resolves #337

* Remove Windows

* Compress binaries

* Use strip

* Fix binary path for Windows
  • Loading branch information
vrom911 authored Jul 9, 2020
1 parent 398f6da commit 6d96b9d
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:

- name: Freeze
run: |
ghc --version
cabal freeze
- uses: actions/cache@v1
Expand Down Expand Up @@ -112,4 +111,4 @@ jobs:
- name: Run HLint
run: |
curl https://raw.githubusercontent.com/kowainik/relude/v0.7.0.0/.hlint.yaml -o .hlint-relude.yaml
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s src/ test/ -h .hlint-relude.yaml
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s src/ test/ -h .hlint-relude.yaml
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Stan Release

on:
# Trigger the workflow on the new 'v*' tag created
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/create-release@v1.1.1
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.8.3"
- "8.10.1"
cabal: ["3.2"]
exclude:
- os: windows-latest
ghc: 8.8.3

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set tag name
uses: olegtarasov/get-tag@v2
id: tag
with:
tagRegex: "v(.*)"
tagRegexGroup: 1

- name: Setup Haskell
uses: actions/setup-haskell@v1.1.1
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:stan --install-method=copy --overwrite-policy=always --installdir=dist
- if: matrix.os == 'windows-latest'
name: Set extension to .exe on Windows
run: echo "::set-env name=EXT::.exe"

- name: Set binary path name
run: echo "::set-env name=BINARY_PATH::./dist/stan${{ env.EXT }}"

- name: Strip binary
run: strip ${{ env.BINARY_PATH }}

# - name: Compress binary
# uses: svenstaro/upx-action@v2
# with:
# file: dist/stan

- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: 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/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ env.BINARY_PATH }}
asset_name: stan-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}
asset_content_type: application/octet-stream
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`stan` uses [PVP Versioning][1].
The change log is available [on GitHub][2].

## Unreleased
## 0.0.1.0 — Jul 9, 2020

* [#320](https://github.com/kowainik/stan/issues/320):
Add `-b|--browse` option to the `report` command.
Expand All @@ -17,6 +17,7 @@ The change log is available [on GitHub][2].
* [#323](https://github.com/kowainik/stan/issues/323):
Add `--json-output` option that output the results in machine readable JSON
format instead. Also all other printing is turned off then.
* Minor documentation improvements.

## 0.0.0.0

Expand Down
2 changes: 1 addition & 1 deletion stan.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: stan
version: 0.0.0.0
version: 0.0.1.0
synopsis: Haskell STatic ANalyser
description:
Stan is a Haskell __ST__atic __AN__alysis CLI tool.
Expand Down

0 comments on commit 6d96b9d

Please sign in to comment.