Skip to content

Commit d34981f

Browse files
Add CI + release workflows
1 parent f9e4e29 commit d34981f

4 files changed

Lines changed: 164 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
workflow_call:
8+
9+
jobs:
10+
build_and_test:
11+
strategy:
12+
matrix:
13+
ghc_version:
14+
- '9.8'
15+
- '9.10'
16+
- '9.12'
17+
- '9.14'
18+
include:
19+
- ghc_version: '9.8.1'
20+
oldest: true
21+
22+
name: build_and_test (${{ matrix.ghc_version }})
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
-
27+
uses: actions/checkout@v3
28+
-
29+
id: setup
30+
name: Set up GHC ${{ matrix.ghc_version }}
31+
uses: haskell-actions/setup@v2
32+
with:
33+
ghc-version: ${{ matrix.ghc_version }}
34+
-
35+
name: Configure the build
36+
run:
37+
cabal configure
38+
--enable-test
39+
--test-show-details=streaming
40+
-
41+
if: ${{ matrix.oldest }}
42+
name: Use oldest dependencies
43+
run: cabal configure --enable-append --prefer-oldest
44+
-
45+
name: Get build plan
46+
run: cabal build --dry-run
47+
-
48+
name: Get current month to clear cache
49+
run: echo "CURR_MONTH=$(date +%B)" | tee -a "$GITHUB_ENV"
50+
-
51+
uses: actions/cache@v3
52+
with:
53+
path: ${{ steps.setup.outputs.cabal-store }}
54+
key: ${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}-${{ hashFiles('**/plan.json') }}
55+
restore-keys: |
56+
${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}-
57+
-
58+
name: Build + Test
59+
run: cabal test
60+
61+
lint:
62+
runs-on: ubuntu-latest
63+
env:
64+
FOURMOLU_VERSION: '0.19.0.1'
65+
steps:
66+
-
67+
uses: actions/checkout@v3
68+
-
69+
name: Install fourmolu
70+
run: |
71+
curl -sSL \
72+
"https://github.com/fourmolu/fourmolu/releases/download/v${FOURMOLU_VERSION}/fourmolu-${FOURMOLU_VERSION}-linux-x86_64" \
73+
-o /usr/local/bin/fourmolu
74+
chmod +x /usr/local/bin/fourmolu
75+
-
76+
name: Run fourmolu
77+
run: fourmolu -m check .
78+
79+
build_sdist:
80+
runs-on: ubuntu-latest
81+
steps:
82+
-
83+
uses: actions/checkout@v3
84+
-
85+
id: setup
86+
name: Set up GHC
87+
uses: haskell-actions/setup@v2
88+
-
89+
name: Strip unreleased section from CHANGELOG
90+
run: sed -i -n '/^## Unreleased/d; /^## /,$p' CHANGELOG.md
91+
-
92+
name: Create sdist bundle
93+
run: cabal sdist --output-directory=.
94+
-
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: kdl-sdist
98+
path: kdl-*.tar.gz

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
on: workflow_dispatch
3+
4+
jobs:
5+
ci:
6+
uses: ./.github/workflows/ci.yml
7+
8+
release:
9+
runs-on: ubuntu-latest
10+
needs:
11+
- ci
12+
13+
steps:
14+
-
15+
uses: actions/checkout@v3
16+
-
17+
uses: actions/download-artifact@v4
18+
with:
19+
name: kdl-sdist
20+
path: ./sdist/
21+
-
22+
id: cabal_file
23+
uses: haskell-actions/parse-cabal-file@v1
24+
with:
25+
cabal_file: kdl.cabal
26+
-
27+
name: Set version label
28+
run: echo 'VERSION=v${{ steps.cabal_file.outputs.version }}' >> "${GITHUB_ENV}"
29+
-
30+
id: hackage_token_secret
31+
name: Load Hackage token secret name
32+
run: |
33+
USERNAME="$(echo "${GITHUB_ACTOR}" | tr '[:lower:]' '[:upper:]' | tr '-' '_')"
34+
echo "name=HACKAGE_TOKEN_${USERNAME}" >> "${GITHUB_OUTPUT}"
35+
-
36+
name: Get CHANGELOG section
37+
run: |
38+
sed '/^## Unreleased/,/^$/d' CHANGELOG.md > /tmp/changelog-without-unreleased
39+
if [[ "$(head -n 1 /tmp/changelog-without-unreleased)" != "## ${VERSION}" ]]; then
40+
echo "CHANGELOG doesn't look updated" >&2
41+
exit 1
42+
fi
43+
sed '1 d; /^## v/,$ d' /tmp/changelog-without-unreleased > /tmp/changelog-body
44+
-
45+
uses: haskell-actions/hackage-publish@v1
46+
with:
47+
hackageToken: ${{ secrets[steps.hackage_token_secret.outputs.name] }}
48+
packagesPath: ./sdist/
49+
-
50+
uses: softprops/action-gh-release@v1
51+
with:
52+
tag_name: ${{ env.VERSION }}
53+
body_path: /tmp/changelog-body
54+
draft: true
55+
target_commitish: ${{ github.sha }}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Unreleased
2+
3+
# v0.1.0
4+
5+
Initial release, with:
6+
7+
* Support for decoding v1 KDL syntax (and a subset of v2 KDL syntax)
8+
* Decoding via Arrows or Monads
9+
* Statically determine decoder schema

kdl-hs.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: kdl-hs
4-
version: 0.0.0
4+
version: 0.1.0
55
synopsis: KDL language parser and API
66
description: KDL language parser and API.
77
homepage: https://github.com/brandonchinn178/kdl-hs#readme
@@ -14,6 +14,7 @@ category: Text
1414
build-type: Simple
1515
extra-source-files:
1616
README.md
17+
CHANGELOG.md
1718

1819
source-repository head
1920
type: git

0 commit comments

Comments
 (0)