Skip to content

Commit 02c61d9

Browse files
committed
ci: add github workflows
1 parent c2a852b commit 02c61d9

File tree

4 files changed

+184
-0
lines changed

4 files changed

+184
-0
lines changed

.github/workflows/cabal-build.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
name: cabal-build
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
branches: master
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: ${{ matrix.os }} / ghc ${{ matrix.ghc-version }}
15+
runs-on: ${{ matrix.os }}-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu]
20+
ghc-version:
21+
- 9.8
22+
- 9.6
23+
- 9.4
24+
- 9.2
25+
26+
include:
27+
- os: windows
28+
ghc-version: 9.6
29+
30+
- os: macos
31+
ghc-version: 9.6
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
36+
- name: Set up GHC ${{ matrix.ghc-version }}
37+
uses: haskell/actions/setup@v2
38+
id: setup
39+
with:
40+
ghc-version: ${{ matrix.ghc-version }}
41+
# Defaults, added for clarity:
42+
cabal-version: latest
43+
cabal-update: true
44+
45+
- name: Configure the build
46+
run: |
47+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
48+
cabal build --dry-run
49+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
50+
51+
- name: Restore cached dependencies
52+
uses: actions/cache/restore@v3
53+
id: cache
54+
env:
55+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
56+
57+
with:
58+
path: ${{ steps.setup.outputs.cabal-store }}
59+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
60+
restore-keys: ${{ env.key }}-
61+
62+
- name: Install dependencies
63+
run: cabal build all --only-dependencies
64+
65+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
66+
- name: Save cached dependencies
67+
uses: actions/cache/save@v3
68+
# Caches are immutable, trying to save with the same key would error.
69+
if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
70+
with:
71+
path: ${{ steps.setup.outputs.cabal-store }}
72+
key: ${{ steps.cache.outputs.cache-primary-key }}
73+
74+
- name: Build
75+
run: cabal build all
76+
77+
- name: Run tests
78+
run: cabal test all
79+
80+
- name: Check cabal file
81+
run: cabal check
82+
continue-on-error: true
83+
84+
- name: Build documentation
85+
run: cabal haddock all
86+
...
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Conventional commits
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
name: Conventional commits
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: webiny/[email protected]
16+
...
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Semantic release
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
name: Semantic release
11+
environment: master
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
persist-credentials: false
17+
18+
- name: Semantic release
19+
id: semantic
20+
uses: cycjimmy/semantic-release-action@v4
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
23+
HACKAGE_TOKEN: ${{ secrets.HACKAGE_TOKEN }}
24+
25+
with:
26+
ci: ${{ env.GITHUB_REF == 'refs/head/master' }}
27+
extra_plugins: |
28+
semantic-release-mirror-version
29+
semantic-release-hackage
30+
31+
- name: Semantic release output
32+
run: |
33+
echo dry_run: ${{ env.GITHUB_REF != 'refs/head/master' }}
34+
echo published: ${{ steps.semantic.outputs.new_release_published }}
35+
echo last_release: ${{ steps.semantic.outputs.last_release_version }}
36+
echo new_version: ${{ steps.semantic.outputs.new_release_version }}
37+
echo git_head: ${{ steps.semantic.outputs.new_release_git_head }}
38+
39+
echo release_notes:
40+
echo "${{ steps.semantic.outputs.new_release_notes }}"
41+
...

.releaserc.mjs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @type {import('semantic-release').GlobalConfig}
3+
*/
4+
export default {
5+
branches: ["master"],
6+
tagFormat: "${version}",
7+
plugins: [
8+
"@semantic-release/commit-analyzer",
9+
"@semantic-release/release-notes-generator",
10+
[
11+
"semantic-release-mirror-version",
12+
{
13+
"fileGlob": "@(package.yaml|megaparsec-utils.cabal)",
14+
"placeholderRegExp": "0.0.0-dev"
15+
}
16+
],
17+
[
18+
"@semantic-release/changelog",
19+
{
20+
changelogFile: "CHANGELOG.md",
21+
changelogTitle: "Changelog"
22+
}
23+
],
24+
[
25+
"@semantic-release/git",
26+
{
27+
assets: [
28+
"CHANGELOG.md",
29+
]
30+
}
31+
],
32+
"@semantic-release/github",
33+
[
34+
"semantic-release-hackage",
35+
{
36+
"versionPrefix": "0.",
37+
"publishDocumentation": true
38+
}
39+
]
40+
]
41+
}

0 commit comments

Comments
 (0)