Skip to content

Commit 64f85e2

Browse files
committed
ci: add github workflows
1 parent d374b28 commit 64f85e2

3 files changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/cabal-build.yml

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

0 commit comments

Comments
 (0)