Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workflow. #11

Merged
merged 26 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@byteverse/l3c
134 changes: 134 additions & 0 deletions .github/check-release.sh
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
84 changes: 84 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 20 additions & 15 deletions json-query.cabal
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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: [email protected]
copyright: 2020 Andrew Martin
category: Data
build-type: Simple
extra-doc-files: CHANGELOG.md

library
exposed-modules:
Expand All @@ -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
Expand Down Expand Up @@ -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
Loading