diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 1bcbf0a..09d0dc6 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -1,113 +1,113 @@ name: Haskell CI on: - workflow_call: - outputs: - MAESTRO_SDK_VERSION: - description: "MAESTRO_SDK_VERSION" - value: ${{ jobs.build.outputs.MAESTRO_SDK_VERSION }} + workflow_call: + outputs: + MAESTRO_SDK_VERSION: + description: "MAESTRO_SDK_VERSION" + value: ${{ jobs.build.outputs.MAESTRO_SDK_VERSION }} permissions: - contents: read + contents: read jobs: - build: - runs-on: ubuntu-22.04 - environment: build - outputs: - MAESTRO_SDK_VERSION: ${{ steps.get_maestro_sdk_version.outputs.MAESTRO_SDK_VERSION }} - steps: - - name: Checkout source code - uses: actions/checkout@v3 - - name: Install dependencies (apt-get) - run: | - sudo apt-get update - sudo apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - build-essential \ - ca-certificates \ - chrony \ - dpkg-dev \ - gcc \ - gnupg \ - g++ \ - hlint \ - libc6-dev \ - libncursesw5 \ - libffi-dev \ - libgmp-dev \ - liblzma-dev \ - libnuma-dev \ - libpq-dev \ - libssl-dev \ - libsystemd-dev \ - libtinfo-dev \ - libtool \ - netbase \ - pkg-config \ - procps \ - tmux \ - xz-utils \ - zlib1g-dev - - name: Setup haskell tooling - uses: haskell/actions/setup@v2 - with: - ghc-version: '8.10.7' - cabal-version: '3.8' - enable-stack: true - stack-version: '2.9' - - name: Setup cache - uses: actions/cache@v3 - env: - cache-name: cache-cabal - with: - path: ~/.cabal - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Update dependencies (cabal) - run: cabal v2-update - - name: Build dependencies (cabal) - run: cabal v2-build --only-dependencies --enable-tests --enable-benchmarks - - name: Build all targets (cabal) - run: cabal v2-build --enable-tests --enable-benchmarks all - # - name: Run all tests (cabal) - # run: cabal v2-test maestro-sdk-tests - - name: Run doctest (docspec) - run: | - # Install docspec and run doctests. - echo "=========================[ INSTALL DOCSPEC ]========================" - echo " -> Started at $(date --iso-8601=seconds --utc)." - curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20211114/cabal-docspec-0.0.0.20211114.xz > ./cabal-docspec.xz - xz -d < ./cabal-docspec.xz > ./cabal-docspec - rm -f ./cabal-docspec.xz - chmod a+x ./cabal-docspec - echo " -> Docspec has been installed." - echo "===========================[ RUN DOCSPEC ]===========================" - ./cabal-docspec - echo " ============================[ FINISHED ]============================" - - name: Run checks (cabal) - run: cabal check - - name: Create source distribution file (cabal) - run: cabal sdist - - name: Identify maestro sdk version (cabal) - id: get_maestro_sdk_version - run: | - export MAESTRO_SDK_VERSION=$(cabal info . | awk '{print $2 ;exit}') ; - echo "MAESTRO_SDK_VERSION: $MAESTRO_SDK_VERSION" - echo "MAESTRO_SDK_VERSION=${MAESTRO_SDK_VERSION}" >> $GITHUB_ENV - echo "MAESTRO_SDK_VERSION=${MAESTRO_SDK_VERSION}" >> $GITHUB_OUTPUT - - name: Generate documentation (cabal haddock) - run: cabal haddock --html --hyperlink-source --haddock-options="--use-unicode" - - name: Upload haddock documentation - uses: actions/upload-pages-artifact@v1.0.8 - with: - path: ./dist-newstyle/build/x86_64-linux/ghc-8.10.7/${{env.MAESTRO_SDK_VERSION}}/doc/html/maestro-sdk/ - - name: Upload artifacts - uses: actions/upload-artifact@v3 - with: - name: source-distribution-file - path: ./dist-newstyle/sdist/${{env.MAESTRO_SDK_VERSION}}.tar.gz + build: + runs-on: ubuntu-22.04 + environment: build + outputs: + MAESTRO_SDK_VERSION: ${{ steps.get_maestro_sdk_version.outputs.MAESTRO_SDK_VERSION }} + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Install dependencies (apt-get) + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + build-essential \ + ca-certificates \ + chrony \ + dpkg-dev \ + gcc \ + gnupg \ + g++ \ + hlint \ + libc6-dev \ + libncursesw5 \ + libffi-dev \ + libgmp-dev \ + liblzma-dev \ + libnuma-dev \ + libpq-dev \ + libssl-dev \ + libsystemd-dev \ + libtinfo-dev \ + libtool \ + netbase \ + pkg-config \ + procps \ + tmux \ + xz-utils \ + zlib1g-dev + - name: Setup haskell tooling + uses: haskell/actions/setup@v2 + with: + ghc-version: "8.10.7" + cabal-version: "3.8" + enable-stack: true + stack-version: "2.9" + - name: Setup cache + uses: actions/cache@v3 + env: + cache-name: cache-cabal + with: + path: ~/.cabal + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Update dependencies (cabal) + run: cabal v2-update + - name: Build dependencies (cabal) + run: cabal v2-build --only-dependencies --enable-tests --enable-benchmarks + - name: Build all targets (cabal) + run: cabal v2-build --enable-tests --enable-benchmarks all + # - name: Run all tests (cabal) + # run: cabal v2-test maestro-sdk-tests + - name: Run doctest (docspec) + run: | + # Install docspec and run doctests. + echo "=========================[ INSTALL DOCSPEC ]========================" + echo " -> Started at $(date --iso-8601=seconds --utc)." + curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20211114/cabal-docspec-0.0.0.20211114.xz > ./cabal-docspec.xz + xz -d < ./cabal-docspec.xz > ./cabal-docspec + rm -f ./cabal-docspec.xz + chmod a+x ./cabal-docspec + echo " -> Docspec has been installed." + echo "===========================[ RUN DOCSPEC ]===========================" + ./cabal-docspec + echo " ============================[ FINISHED ]============================" + - name: Run checks (cabal) + run: cabal check + - name: Create source distribution file (cabal) + run: cabal sdist + - name: Identify maestro sdk version (cabal) + id: get_maestro_sdk_version + run: | + export MAESTRO_SDK_VERSION=$(cabal info . | awk '{print $2 ;exit}') ; + echo "MAESTRO_SDK_VERSION: $MAESTRO_SDK_VERSION" + echo "MAESTRO_SDK_VERSION=${MAESTRO_SDK_VERSION}" >> $GITHUB_ENV + echo "MAESTRO_SDK_VERSION=${MAESTRO_SDK_VERSION}" >> $GITHUB_OUTPUT + - name: Generate documentation (cabal haddock) + run: cabal haddock --html --hyperlink-source --haddock-options="--use-unicode" + - name: Upload haddock documentation + uses: actions/upload-pages-artifact@v3 + with: + path: ./dist-newstyle/build/x86_64-linux/ghc-8.10.7/${{env.MAESTRO_SDK_VERSION}}/doc/html/maestro-sdk/ + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: source-distribution-file + path: ./dist-newstyle/sdist/${{env.MAESTRO_SDK_VERSION}}.tar.gz diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ea5271..1f3192d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,67 +1,67 @@ name: Release on: - push: - tags: - - "v*" + push: + tags: + - "v*" permissions: - contents: write + contents: write jobs: - build: - uses: ./.github/workflows/haskell.yml - release: - 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 - - uses: haskell-actions/hackage-publish@v1 - with: - hackageToken: ${{ secrets.HACKAGE_AUTH_TOKEN }} - packagesPath: ${{ runner.temp }}/ - publish: false + build: + uses: ./.github/workflows/haskell.yml + release: + runs-on: ubuntu-22.04 + needs: build + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - uses: actions/download-artifact@v4 + name: Download source distribution file artifact + with: + name: source-distribution-file + path: ./artifacts + - uses: actions/download-artifact@v4 + 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 + - uses: haskell-actions/hackage-publish@v1 + with: + hackageToken: ${{ secrets.HACKAGE_AUTH_TOKEN }} + packagesPath: ${{ runner.temp }}/ + publish: false