diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f6c0b22 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +@byteverse/l3c diff --git a/.github/check-release.sh b/.github/check-release.sh new file mode 100755 index 0000000..9bc62ed --- /dev/null +++ b/.github/check-release.sh @@ -0,0 +1,134 @@ +#!/bin/bash +set -e + +# Perform pre-release checks. +# Args: +# version number +# maintainer email address + +CABAL_FILE=$(ls *.cabal) +CHANGELOG_FILE="CHANGELOG.md" + +die () { + echo + echo >&2 "$@" + echo + exit 1 +} + +# Main +[ "$#" -eq 2 ] || die "Specify release version number and maintainer's email address." + +RELEASE_VERSION="$1" +MAINTAINER_EMAIL="$2" + +echo "Running pre-release checks for version ${RELEASE_VERSION}" + +# Ensure version number in cabal file matches release version. +CABAL_VERSION=$(awk '$1=="version:"{print $2}' "${CABAL_FILE}") + +if [ -z ${CABAL_VERSION} ]; +then + die "Couldn't find version number in ${CABAL_FILE}" +fi + +CABAL_VERSION_VALID=true +if [ ${CABAL_VERSION} != ${RELEASE_VERSION} ]; +then + CABAL_VERSION_VALID=false + echo "You need to update the version number in ${CABAL_FILE} to ${RELEASE_VERSION}" +fi + +# Ensure git url is correct in cabal file. +CABAL_GIT_URL=$(awk '$1=="bug-reports:"{print $2}' "${CABAL_FILE}") + +if [ -z ${CABAL_GIT_URL} ]; +then + die "Couldn't find bug-reports field in ${CABAL_FILE}" +fi + +REPO_GIT_URL=$(git config --get remote.origin.url) +EXPECTED_GIT_URL="${REPO_GIT_URL%.git}" + +CABAL_GIT_URL_VALID=true +if [ ${CABAL_GIT_URL} != ${EXPECTED_GIT_URL} ]; +then + CABAL_GIT_URL_VALID=false + echo "You need to change the bug-reports field in ${CABAL_FILE} to ${EXPECTED_GIT_URL}" +fi + +# Ensure homepage field exists in cabal file and is correct. +CABAL_HOMEPAGE=$(awk '$1=="homepage:"{print $2}' "${CABAL_FILE}") + +if [ -z ${CABAL_HOMEPAGE} ]; +then + die "Couldn't find homepage field in ${CABAL_FILE}" +fi + +CABAL_HOMEPAGE_VALID=true +if [ ${CABAL_HOMEPAGE} != ${EXPECTED_GIT_URL} ]; +then + CABAL_HOMEPAGE_VALID=false + echo "You need to change the homepage field in ${CABAL_FILE} to ${EXPECTED_GIT_URL}" +fi + +# Ensure maintainer email address is correct in cabal file. +CABAL_EMAIL=$(awk '$1=="maintainer:"{print $2}' "${CABAL_FILE}") + +if [ -z ${CABAL_EMAIL} ]; +then + die "Couldn't find maintainer field in ${CABAL_FILE}" +fi + +CABAL_EMAIL_VALID=true +if [ ${CABAL_EMAIL} != ${MAINTAINER_EMAIL} ]; +then + CABAL_EMAIL_VALID=false + echo "You need to change the maintainer field in ${CABAL_FILE} to ${MAINTAINER_EMAIL}" +fi + +# Ensure source-repository entry exists and is correct. +EXPECTED_SOURCE_REPOSITORY_LOCATION="${EXPECTED_GIT_URL#https:\/\/}" +CABAL_SOURCE_REPOSITORY=$(awk '$1=="source-repository"{print $1}' "${CABAL_FILE}") + +if [ -z ${CABAL_SOURCE_REPOSITORY} ]; +then + die "Couldn't find source-repository field in ${CABAL_FILE}" +fi + +FULL_GIT_URL="git://${EXPECTED_SOURCE_REPOSITORY_LOCATION}.git" +CABAL_SOURCE_REPOSITORY_LOCATION=$(awk '$1=="location:"{print $2}' "${CABAL_FILE}") + +CABAL_SOURCE_REPOSITORY_VALID=true +if [ ${CABAL_SOURCE_REPOSITORY_LOCATION} != "${FULL_GIT_URL}" ]; +then + CABAL_SOURCE_REPOSITORY_VALID=false + echo "You need to change the source-repository's location in ${CABAL_FILE} to ${FULL_GIT_URL}" +fi + +# Ensure changelog contains an entry for this release version. +CHANGELOG_VERSION=$(grep -Eo "##\s+${RELEASE_VERSION}" "${CHANGELOG_FILE}" || true) + +CHANGELOG_VERSION_VALID=true +if [ -z "${CHANGELOG_VERSION}" ]; +then + CHANGELOG_VERSION_VALID=false + echo "You need to add an entry in ${CHANGELOG_FILE} for version ${RELEASE_VERSION}" +fi + +CHECKS=( + "$CABAL_VERSION_VALID" + "$CABAL_GIT_URL_VALID" + "$CABAL_HOMEPAGE_VALID" + "$CABAL_EMAIL_VALID" + "$CABAL_SOURCE_REPOSITORY_VALID" + "$CHANGELOG_VERSION_VALID" +) + +if [[ ${CHECKS[*]} == *false* ]]; +then + die "Please correct errors and commit them before trying again." +fi + +echo "Everything looks good." +echo diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..ee6d9a6 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,41 @@ +name: build +on: + pull_request: + branches: + - "*" + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +env: + ghc-version: 9.4.7 + cabal-version: 3.10.1.0 + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set up GHC ${{ env.ghc-version }} + uses: haskell-actions/setup@latest + id: setup + with: + ghc-version: ${{ env.ghc-version }} + cabal-version: ${{ env.cabal-version }} + cabal-update: true + + - name: Configure the build + run: | + cabal configure --enable-tests --enable-benchmarks --disable-documentation + cabal build all --dry-run + + - name: Install dependencies + run: cabal build all --only-dependencies + + - name: Build + run: cabal build all + + - name: Run tests + run: cabal test all diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..8b01bba --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,84 @@ +name: release +on: + push: + tags: + - "*" + +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: true + +env: + ghc-version: 9.4.7 + cabal-version: 3.10.1.0 + maintainer-email: ${{ vars.MAINTAINER_EMAIL }} + tag: ${{ github.ref_name }} + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Acquire access token + id: access-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.GITBOT_APP_ID }} + private-key: ${{ secrets.GITBOT_APP_PRIVATE_KEY }} + + - name: Run Pre-Release Checks + run: | + ./.github/check-release.sh "${{ env.tag }}" "${{ env.maintainer-email }}" + if [ $? -ne 0 ]; + then + echo "${RESULT}" + exit 1 + fi + + - name: Set up GHC ${{ env.ghc-version }} + uses: haskell-actions/setup@latest + id: setup + with: + ghc-version: ${{ env.ghc-version }} + cabal-version: ${{ env.cabal-version }} + cabal-update: true + + - name: Configure the build + run: | + cabal configure --enable-tests --enable-benchmarks --disable-documentation + cabal build all --dry-run + + - name: Install dependencies + run: cabal build all --only-dependencies + + - name: Build + run: cabal build all + + - name: Run tests + run: cabal test all + + - name: Check cabal file + run: cabal check + + - name: Build source archive + run: cabal sdist --output-directory ./dist-newstyle + + - name: Build documentation archive + run: | + PKG_VERSION="${{ github.event.repository.name }}-${{ env.tag }}" + cabal haddock \ + --haddock-html-location='https://hackage.haskell.org/package/${PKG_VERSION}/docs' \ + --haddock-hyperlink-source \ + --haddock-quickjump \ + --haddock-for-hackage + + - name: Create release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ steps.access-token.outputs.token }} + with: + allowUpdates: true + artifacts: "./dist-newstyle/*.tar.gz" + artifactErrorsFailBuild: true + generateReleaseNotes: true diff --git a/json-query.cabal b/json-query.cabal index 8aa91e8..f49aef6 100644 --- a/json-query.cabal +++ b/json-query.cabal @@ -1,21 +1,22 @@ -cabal-version: 2.4 -name: json-query -version: 0.2.3.0 -synopsis: Kitchen sink for querying JSON +cabal-version: 2.4 +name: json-query +version: 0.2.3.0 +synopsis: Kitchen sink for querying JSON description: The library complements json-syntax by making available several common access patterns. The utilities provided by this library only query JSON. They do not update it. -bug-reports: https://github.com/andrewthad/json-query -license: BSD-3-Clause -license-file: LICENSE -author: Andrew Martin -maintainer: andrew.thaddeus@gmail.com -copyright: 2020 Andrew Martin -category: Data -build-type: Simple -extra-source-files: CHANGELOG.md +homepage: https://github.com/byteverse/json-query +bug-reports: https://github.com/byteverse/json-query +license: BSD-3-Clause +license-file: LICENSE +author: Andrew Martin +maintainer: amartin@layer3com.com +copyright: 2020 Andrew Martin +category: Data +build-type: Simple +extra-doc-files: CHANGELOG.md library exposed-modules: @@ -31,11 +32,11 @@ library , base >=4.12 && <5 , bytebuild >=0.3.5 && <0.4 , bytestring >=0.10 && <0.12 - , contiguous >=0.6.1 + , contiguous >=0.6.4 && <0.7 , json-syntax >=0.2.2 && <0.3 , primitive >=0.7 && <0.10 , primitive-unlifted >=0.1.3 && <2.2 - , profunctors >=5.6 + , profunctors >=5.6.2 && <5.7 , scientific-notation >=0.1.5 && <0.2 , text-short >=0.1.3 && <0.2 , transformers >=0.5.6 && <0.7 @@ -72,3 +73,7 @@ test-suite test , tasty-hunit >=0.10.0.2 , text >=1.2 , text-short + +source-repository head + type: git + location: git://github.com/byteverse/json-query.git