diff --git a/.github/actions/publish-haskell/action.yml b/.github/actions/publish-haskell/action.yml new file mode 100644 index 0000000..d3e9cb8 --- /dev/null +++ b/.github/actions/publish-haskell/action.yml @@ -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 }} diff --git a/.github/actions/publish-node/action.yml b/.github/actions/publish-node/action.yml index a9c0a41..7a85d1c 100644 --- a/.github/actions/publish-node/action.yml +++ b/.github/actions/publish-node/action.yml @@ -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: diff --git a/.github/workflows/build-haskell.yml b/.github/workflows/build-haskell.yml deleted file mode 100644 index 898bd04..0000000 --- a/.github/workflows/build-haskell.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: "Build Haskell Package" - -on: - workflow_call: {} - -jobs: - build: - runs-on: ubuntu-latest - env: - HASKELL_ROOT: gen/haskell - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install protoc - run: | - PROTOC_ZIP=protoc-3.14.0-linux-x86_64.zip - curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$PROTOC_ZIP - unzip -o $PROTOC_ZIP -d . bin/protoc - unzip -o $PROTOC_ZIP -d . 'include/*' - rm -f $PROTOC_ZIP - echo "$(pwd)/bin" >> "$GITHUB_PATH" - - - name: Get Haskell codegen artifact - id: download-haskell-codegen - uses: actions/download-artifact@v4 - with: - name: codegen - path: gen - - - name: Setup Haskell - id: setup-hs - uses: haskell-actions/setup@v2 - with: - ghc-version: 9.6.4 - - - name: Configure Cabal build - run: | - cd ${{ env.HASKELL_ROOT }} - 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 - run: | - cd ${{ env.HASKELL_ROOT }} - 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 - env: - version: ${{ steps.package-version.outputs.VERSION }} - run: | - cd ${{ env.HASKELL_ROOT }} - cabal build - cabal sdist - echo "SDIST-LOCATION=$(pwd)/dist-newstyle/sdist/utxorpc-${{ env.version }}.tar.gz" >> "$GITHUB_OUTPUT" - - - name: Upload Haskell Artifacts - 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 }} diff --git a/.github/workflows/publish-all.yml b/.github/workflows/publish-all.yml index 87b4f79..d493508 100644 --- a/.github/workflows/publish-all.yml +++ b/.github/workflows/publish-all.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a32d668..3ca9e39 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,3 @@ jobs: secrets: inherit with: mode: "release" - - build-haskell: - needs: [generate] - uses: ./.github/workflows/build-haskell.yml