Skip to content

Commit

Permalink
new and simpler release action - let's see if it works
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrome committed May 3, 2024
1 parent 55fd547 commit 97dec5c
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 143 deletions.
160 changes: 17 additions & 143 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# taken from https://vrom911.github.io/blog/github-actions-releases

name: Release

on:
Expand All @@ -23,14 +21,13 @@ jobs:
name: Release ${{ github.ref_name }}
draft: true

build_linux_artifact:
build_normal_artifacts:
needs: [create_release]
name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref_name }}
name: ${{ matrix.os }}/${{ github.ref }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04] # old version is on purpose: to compile with old libc
ghc: ["9.4.7"]
os: [ubuntu-20.04, macOS-latest, windows-latest]

steps:
- name: Check out code
Expand All @@ -43,27 +40,24 @@ jobs:
tagRegex: "v(.*)"
tagRegexGroup: 1

- name: Setup Haskell
uses: haskell-actions/setup@v2
id: setup-haskell-cabal
- name: Build executable
uses: freckle/stack-action@v5
id: stack
with:
ghc-version: ${{ matrix.ghc }}

- name: Freeze
run: cabal freeze

- name: Build
run: |
mkdir dist
cabal install exe:trident --install-method=copy --overwrite-policy=always --installdir=dist -fembed_data_files
stack-arguments: --copy-bins

- name: Set binary path name
id: binarypath
run: |
currentEXE="./dist/trident"
newEXE="trident-$RUNNER_OS"
mv $currentEXE $newEXE
echo "BINARY_PATH=$newEXE" >> $GITHUB_OUTPUT
if [ "$RUNNER_OS" == "Windows" ]; then
newEXE="trident-$RUNNER_OS.exe"
else
newEXE="trident-$RUNNER_OS"
fi
currentEXE="${{ steps.stack.outputs.local-bin }}/trident"
mv $currentEXE $newEXE
echo "BINARY_PATH=$newEXE" >> $GITHUB_OUTPUT
shell: bash

- name: Compress binary
uses: svenstaro/upx-action@v2
Expand All @@ -81,126 +75,6 @@ jobs:
artifacts: ${{ steps.binarypath.outputs.BINARY_PATH }}
artifactContentType: application/octet-stream

build_mac_artifact:
needs: [create_release]
name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref_name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macOS-latest]
ghc: ["9.4.7"]

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

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

- name: Install pkgconfig (for the dependency "digest")
run: brew install pkg-config

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

- name: Freeze
run: |
: # simdutf doesn't build on macOS any more, so we need to set a flag to ignore it when building the text package
cabal freeze --constraint="any.text >= 2.0.1" --constraint="any.text -simdutf"
- name: Build
run: |
mkdir dist
cabal install exe:trident --install-method=copy --overwrite-policy=always --installdir=dist -fembed_data_files
- name: Set binary path name
id: binarypath
run: |
currentEXE="./dist/trident"
newEXE="trident-$RUNNER_OS"
mv $currentEXE $newEXE
echo "BINARY_PATH=$newEXE" >> $GITHUB_OUTPUT
- name: Compress binary
uses: svenstaro/upx-action@v2
with:
files: ${{ steps.binarypath.outputs.BINARY_PATH }}

- name: Upload Release Asset
id: upload-release-asset
uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
draft: true
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: ${{ steps.binarypath.outputs.BINARY_PATH }}
artifactContentType: application/octet-stream

build_windows_artifact:
needs: [create_release]
name: ${{ matrix.os }}/GHC ${{ matrix.ghc }}/${{ github.ref_name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
ghc: ["9.4.7"]

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

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

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

- name: Freeze
run: |
cabal freeze
- name: Build
run: |
mkdir dist
cabal install exe:trident --install-method=copy --overwrite-policy=always --installdir=dist -fembed_data_files
- name: Set binary path name
id: binarypath
run: |
Rename-Item -Path "./dist/trident.exe" -NewName "trident-Windows.exe"
echo "BINARY_PATH=./dist/trident-Windows.exe" >> $env:GITHUB_OUTPUT
- name: Compress binary
uses: svenstaro/upx-action@v2
with:
files: ${{ steps.binarypath.outputs.BINARY_PATH }}

- name: Upload Release Asset
id: upload-release-asset
uses: ncipollo/release-action@v1
with:
name: Release ${{ github.ref_name }}
draft: true
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: ${{ steps.binarypath.outputs.BINARY_PATH }}
artifactContentType: application/octet-stream

build_centos_artifact:
needs: [create_release]
runs-on: ubuntu-latest
Expand All @@ -227,4 +101,4 @@ jobs:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: trident-conda-linux
artifactContentType: application/octet-stream
artifactContentType: application/octet-stream
Loading

0 comments on commit 97dec5c

Please sign in to comment.