Skip to content

Commit

Permalink
Create release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
folivetti committed Sep 4, 2024
1 parent 0b62439 commit 561111c
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: srtols Release

on: push
# Trigger the workflow on the new 'v*' tag created
#push:
# tags:
# - "v*"

jobs:
create_release:
name: Create Github Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false

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:
- 9.6.6
cabal: ["3.12.1.0"]
defaults:
run:
shell: bash

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

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

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

- name: Cache ~/.cabal/store
uses: actions/cache@v2
with:
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.sha }}
path: ~/.cabal/store

- name: Build binary
run: |
mkdir dist
cabal install exe:srsimplify --install-method=copy --overwrite-policy=always --installdir=dist
cabal install exe:srtools --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_PATH1=./dist/srsimplify${{ env.EXT }}" >> $GITHUB_ENV
echo "BINARY_PATH2=./dist/srtools${{ env.EXT }}" >> $GITHUB_ENV
- name: Compress binary
uses: svenstaro/upx-action@2.0.1
with:
file: ${{ env.BINARY_PATH }}

- name: Upload Release Asset
id: upload-release-asset
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ env.BINARY_PATH1 }}/srsimplify-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}
${{ env.BINARY_PATH2 }}/srtools-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }}

0 comments on commit 561111c

Please sign in to comment.