Skip to content

Commit

Permalink
test hackage
Browse files Browse the repository at this point in the history
  • Loading branch information
Vardominator committed Aug 20, 2024
1 parent 91df7c3 commit 5e9995b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 74 deletions.
104 changes: 53 additions & 51 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- "v*"
branches: ["test-hackage"]

permissions:
contents: write
Expand All @@ -15,54 +16,55 @@ jobs:
runs-on: ubuntu-22.04
needs: build
steps:
- name: Checkout source code
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
name: Download source distribution file artifact
with:
name: source-distribution-file
path: ./artifacts
- uses: actions/download-artifact@v3
name: Download haddock artifact
with:
name: github-pages
path: ./artifacts
- name: Create release draft (GitHub)
env:
MAESTRO_SDK_VERSION: ${{needs.build.outputs.MAESTRO_SDK_VERSION}}
run: |
export GH_TOKEN=${{ secrets.GITHUB_TOKEN }}
SEMANTIC_VERSION=v${MAESTRO_SDK_VERSION/#maestro-sdk-}
TAGS=$(git describe --tags)
GIT_REVISION=$(git rev-parse HEAD)
CI_BUILD_TIME=$(date --iso-8601=seconds --utc)
echo "MAESTRO_SDK_VERSION: ${{ env.MAESTRO_SDK_VERSION }}"
echo "SEMANTIC_VERSION: $SEMANTIC_VERSION"
echo "TAGS: $TAGS"
echo "GIT_REVISION: $GIT_REVISION"
echo "CI_BUILD_TIME: $CI_BUILD_TIME"
HADDOCK_FILE=${{ env.MAESTRO_SDK_VERSION }}-haddock.tar
set -x
mv ./artifacts/artifact.tar ./artifacts/${HADDOCK_FILE}
gh release create \
--generate-notes \
--verify-tag \
--draft \
"${SEMANTIC_VERSION}" \
"./artifacts/${{ env.MAESTRO_SDK_VERSION }}.tar.gz#Source distribution file (tar.gz)" \
"./artifacts/${HADDOCK_FILE}#Haddock (tar)"
echo "::notice::Succesfully created release draft ${SEMANTIC_VERSION} from ${GIT_REVISION}. (Uploaded: ${{ env.MAESTRO_SDK_VERSION }}.tar.gz)"
- name: Setup haskell tooling
uses: haskell/actions/setup@v2
with:
ghc-version: '8.10.7'
cabal-version: '3.8'
enable-stack: true
- name: Update dependencies (cabal)
run: cabal v2-update
# - name: Publish to Hackage (cabal)
# run: |
# dir=$(mktemp -d dist-docs.XXXXXX)
# trap 'rm -r "$dir"' EXIT
# cabal v2-haddock --builddir="$dir" --haddock-for-hackage --enable-doc
# cabal upload -d --publish $dir/*-docs.tar.gz
- name: Checkout source code
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
name: Download source distribution file artifact
with:
name: source-distribution-file
path: ./artifacts
- uses: actions/download-artifact@v3
name: Download haddock artifact
with:
name: github-pages
path: ./artifacts
- name: Create release draft (GitHub)
env:
MAESTRO_SDK_VERSION: ${{needs.build.outputs.MAESTRO_SDK_VERSION}}
run: |
export GH_TOKEN=${{ secrets.GITHUB_TOKEN }}
SEMANTIC_VERSION=v${MAESTRO_SDK_VERSION/#maestro-sdk-}
TAGS=$(git describe --tags)
GIT_REVISION=$(git rev-parse HEAD)
CI_BUILD_TIME=$(date --iso-8601=seconds --utc)
echo "MAESTRO_SDK_VERSION: ${{ env.MAESTRO_SDK_VERSION }}"
echo "SEMANTIC_VERSION: $SEMANTIC_VERSION"
echo "TAGS: $TAGS"
echo "GIT_REVISION: $GIT_REVISION"
echo "CI_BUILD_TIME: $CI_BUILD_TIME"
HADDOCK_FILE=${{ env.MAESTRO_SDK_VERSION }}-haddock.tar
set -x
mv ./artifacts/artifact.tar ./artifacts/${HADDOCK_FILE}
gh release create \
--generate-notes \
--verify-tag \
--draft \
"${SEMANTIC_VERSION}" \
"./artifacts/${{ env.MAESTRO_SDK_VERSION }}.tar.gz#Source distribution file (tar.gz)" \
"./artifacts/${HADDOCK_FILE}#Haddock (tar)"
echo "::notice::Succesfully created release draft ${SEMANTIC_VERSION} from ${GIT_REVISION}. (Uploaded: ${{ env.MAESTRO_SDK_VERSION }}.tar.gz)"
- name: Setup haskell tooling
uses: haskell/actions/setup@v2
with:
ghc-version: "8.10.7"
cabal-version: "3.8"
enable-stack: true
- name: Update dependencies (cabal)
run: cabal v2-update
- name: Publish to Hackage
uses: haskell-actions/hackage-publish@v1
with:
hackageToken: ${{ secrets.HACKAGE_AUTH_TOKEN }}
packagesPath: ${{ runner.temp }}/packages
docsPath: ${{ runner.temp }}/docs
publish: false
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,35 @@
1. Add `maestro-sdk` to the `build-depends` of your project.
2. Create a [Maestro API key](https://docs.gomaestro.org/docs/Getting-started/Sign-up-login).
3. Code below explains sample usage.
```haskell
module Main (main) where

import Control.Exception (try)
import Maestro.Client.V1 -- @Maestro.Client.V1@ defines all the client utilities to query Maestro API endpoints.
import Maestro.Types.V1 -- @Maestro.Types.V1@ defines all the types used.
```haskell
module Main (main) where

main :: IO ()
main = do
env <- mkMaestroEnv @'V1 "<Your-API-Key>" Preprod defaultBackoff -- This is how we create an environment against which we'll query endpoints.
chainTip :: ChainTip <- getTimestampedData <$> getChainTip env -- Maestro endpoint to get for chain-tip has data & timestamp against which data was calculated. All endpoints which are timestamped, has functions `getTimestampedData` to get for underlying data & `getTimestamp` to get the timestamp.
addressesUTxOs :: Either MaestroError [UtxoWithSlot] <-
try -- To catch for any errors, given in type `MaestroError`.
$ allPages -- Since this endpoint is paged, we have a helper utility `allPages` to accumulate data from all the pages.
$ flip
(
utxosAtMultiAddresses env
(Just True) -- We would like to have datums resolved. This is for @resolve_datums@ query parameter.
(Just False) -- We would not like to include CBOR encodings of the transaction outputs in the response.
) ["addr_test1...", "addr_test1...", "addr_test1..."] -- Mention your list of addresses to query for.
print addressesUTxOs
```
import Control.Exception (try)
import Maestro.Client.V1 -- @Maestro.Client.V1@ defines all the client utilities to query Maestro API endpoints.
import Maestro.Types.V1 -- @Maestro.Types.V1@ defines all the types used.

main :: IO ()
main = do
env <- mkMaestroEnv @'V1 "<Your-API-Key>" Preprod defaultBackoff -- This is how we create an environment against which we'll query endpoints.
chainTip :: ChainTip <- getTimestampedData <$> getChainTip env -- Maestro endpoint to get for chain-tip has data & timestamp against which data was calculated. All endpoints which are timestamped, has functions `getTimestampedData` to get for underlying data & `getTimestamp` to get the timestamp.
addressesUTxOs :: Either MaestroError [UtxoWithSlot] <-
try -- To catch for any errors, given in type `MaestroError`.
$ allPages -- Since this endpoint is paged, we have a helper utility `allPages` to accumulate data from all the pages.
$ flip
(
utxosAtMultiAddresses env
(Just True) -- We would like to have datums resolved. This is for @resolve_datums@ query parameter.
(Just False) -- We would not like to include CBOR encodings of the transaction outputs in the response.
) ["addr_test1...", "addr_test1...", "addr_test1..."] -- Mention your list of addresses to query for.
print addressesUTxOs
```

# Documentation

* [SDK Haddock](https://haddock.gomaestro.org/)
* [Maestro public docs](https://docs.gomaestro.org/)
* [Maestro API reference](https://docs.gomaestro.org/docs/category/rest-api-reference)
- [SDK Haddock](https://haddock.gomaestro.org/)
- [Maestro public docs](https://docs.gomaestro.org/)
- [Maestro API reference](https://docs.gomaestro.org/docs/category/rest-api-reference)

# Contributing

Expand Down

0 comments on commit 5e9995b

Please sign in to comment.