Skip to content

Commit c292788

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

3 files changed

Lines changed: 145 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.10"
22+
- "9.8"
23+
- "9.6"
24+
25+
include:
26+
- os: windows
27+
ghc-version: "9.10"
28+
29+
- os: macos
30+
ghc-version: "9.10"
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: Semantic release
3+
if: false
4+
5+
jobs:
6+
build:
7+
name: Semantic release
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
persist-credentials: false
13+
14+
- uses: actions/create-github-app-token@v2
15+
id: app-token
16+
with:
17+
app-id: "${{ secrets.SEMANTIC_RELEASE_APP_ID }}"
18+
private-key: "${{ secrets.SEMANTIC_RELEASE_PRIVATE_KEY }}"
19+
20+
- name: Semantic release
21+
id: semantic
22+
uses: cycjimmy/semantic-release-action@v4
23+
env:
24+
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"
25+
26+
with:
27+
ci: ${{ github.ref == github.event.repository.default_branch }}
28+
extra_plugins: |
29+
conventional-changelog-conventionalcommits
30+
semantic-release-mirror-version
31+
32+
- name: Semantic release output
33+
run: |
34+
echo default_branch: ${{ github.event.repository.default_branch }}
35+
echo ref: ${{ github.ref_name }}
36+
echo dry_run: ${{ github.ref_name != github.event.repository.default_branch }}
37+
echo published: ${{ steps.semantic.outputs.new_release_published }}
38+
echo last_release: ${{ steps.semantic.outputs.last_release_version }}
39+
echo new_version: ${{ steps.semantic.outputs.new_release_version }}
40+
echo git_head: ${{ steps.semantic.outputs.new_release_git_head }}
41+
42+
echo release_notes:
43+
echo "${{ steps.semantic.outputs.new_release_notes }}"
44+
...

0 commit comments

Comments
 (0)