Skip to content

Commit

Permalink
ci: move haskell build to action
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Feb 10, 2024
1 parent f582c56 commit 3a5556d
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 92 deletions.
75 changes: 75 additions & 0 deletions .github/actions/publish-haskell/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 'publish haskell'
description: 'Publishes Haskell codegen spec to Hackage (WIP)'
inputs:
registry-token:
description: token to authenticate to Hackage registry
required: false
mode:
description: supported values are 'release' and 'dry-run'
required: true

runs:
using: 'composite'

steps:
- name: Setup Haskell
id: setup-hs
uses: haskell-actions/setup@v2
with:
ghc-version: 9.6.4

- name: Configure Cabal build
shell: bash
working-directory: codegen/haskell
run: |
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run
# ^ Creates a plan.json file equivalent to a package-lock.json, used for creating a cache key

- name: Restore Cabal build cache
uses: actions/cache/restore@v4
id: cache-cabal-build
env:
key: ${{ runner.os }}-ghc-${{ steps.setup-hs.outputs.ghc-version
}}-cabal-${{ steps.setup-hs.outputs.cabal-version }}
with:
path: ${{ steps.setup-hs.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: |
${{ env.key }}-
- name: Get Package Version
id: package-version
shell: bash
working-directory: codegen/haskell
run: |
VERSION=$(sed -nE '/^version:\s*([0-9]\.[0-9]+\.[0-9]+.*)$/s||\1|p' utxorpc.cabal)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build Haskell Library
id: build
shell: bash
working-directory: codegen/haskell
env:
version: ${{ steps.package-version.outputs.VERSION }}
run: |
cabal build
cabal sdist
echo "SDIST-LOCATION=$(pwd)/dist-newstyle/sdist/utxorpc-${{ env.version }}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Upload Haskell Artifacts
if: inputs.mode == 'release'
uses: actions/upload-artifact@v4
env:
version: ${{ steps.package-version.outputs.VERSION }}
location: ${{ steps.build.outputs.SDIST-LOCATION }}
with:
name: haskell-${{ env.version }}
path: ${{ env.location }}

- name: Cache Cabal
if: steps.cache-cabal-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ steps.setup-hs.outputs.cabal-store }}
key: ${{ steps.cache-cabal-build.outputs.cache-primary-key }}
2 changes: 1 addition & 1 deletion .github/actions/publish-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
description: token to authenticate to npmjs.org
required: false
mode:
description: supporte values are 'release' and 'dry-run'
description: supported values are 'release' and 'dry-run'
required: true

runs:
Expand Down
87 changes: 0 additions & 87 deletions .github/workflows/build-haskell.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/publish-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ jobs:
with:
repository-token: ${{ secrets.GOSDK_REPOSITORY_TOKEN }}
mode: ${{ inputs.mode }}

publish-haskell:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: codegen
path: ./codegen

- uses: ./.github/actions/publish-haskell
with:
repository-token: ${{ secrets.HACKAGE_REGISTRY_TOKEN }}
mode: ${{ inputs.mode }}
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ jobs:
secrets: inherit
with:
mode: "release"

build-haskell:
needs: [generate]
uses: ./.github/workflows/build-haskell.yml

0 comments on commit 3a5556d

Please sign in to comment.