forked from kadena-io/kda-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
200 lines (170 loc) · 5.17 KB
/
build.yml
File metadata and controls
200 lines (170 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Build
on:
workflow_dispatch:
push:
paths:
- '**'
- '!.github/**'
- '.github/workflows/applications.yml'
jobs:
build:
if: "!startsWith(github.ref, 'refs/tags/')"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.10.3"]
cabal: ["3.12"]
os: ["ubuntu-22.04", "ubuntu-24.04", "macos-14", "macos-15"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit_sha || github.sha }}
- name: Extract version from cabal file
run: |
VERSION=$(grep -E '^version:' kda-tool.cabal | awk '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Haskell Setup
- name: Set permissions for .ghcup (ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
run: sudo chown -R $USER /usr/local/.ghcup
- name: Install GHC and Cabal
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Confirm GHC and Cabal installation
run: |
ghc --version
cabal --version
- name: Setting up MPFR (Ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
shell: bash
run: sudo apt-get update && sudo apt-get install -y libmpfr-dev
# Project Setup
- name: Create cabal.project.local
shell: bash
run: |
cat > cabal.project.local <<EOF
documentation: False
package pact
tests: True
benchmarks: True
documentation: False
optimization: 1
flags: ${{ matrix.flags }} +cryptonite-ed25519
extra-include-dirs:
/opt/local/include
/usr/local/opt/openssl/include
extra-lib-dirs:
/opt/local/lib
/usr/local/opt/openssl/lib/
EOF
- name: Extend cabal.project.local for GHC-9.0.2
if: "startsWith(matrix.ghc, '9')"
shell: bash
run: |
cat >> cabal.project.local <<EOF
package pact
ghc-options: -Wwarn -Wunused-packages
EOF
- name: Add check for unused packages
shell: bash
run: |
cat >> cabal.project.local <<EOF
package pact
ghc-options: -Wunused-packages
EOF
- name: Print cabal.project.local
shell: bash
run: cat cabal.project.local
- name: Update package database
shell: bash
run: cabal update
- name: Configure build / and freeze
run: |
cabal build --dry-run
cabal freeze
- name: Generate cache key
id: cache-key
run: |
grep -v '^index-state:' cabal.project.freeze > freeze-deps-only
FREEZE_HASH=$(shasum freeze-deps-only | cut -d' ' -f1)
echo "freeze-hash=$FREEZE_HASH" >> $GITHUB_OUTPUT
rm freeze-deps-only
- name: Restore Cabal store
id: restore-cabal
uses: actions/cache/restore@v5
with:
path: ~/.cabal/store
key: cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-key.outputs.freeze-hash }}
restore-keys: |
cabal-${{ matrix.os }}-${{ matrix.ghc }}
- name: Build dependencies
if: steps.restore-cabal.outputs.cache-hit != 'true'
shell: bash
run: cabal build --only-dependencies
- name: Cache Cabal store if necessary
if: steps.restore-cabal.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ~/.cabal/store
key: cabal-${{ matrix.os }}-${{ matrix.ghc }}-${{ steps.cache-key.outputs.freeze-hash }}
- name: Build
shell: bash
run: cabal build
- name: Verify Binary Linking
shell: bash
run: cabal run exe:kda -- --help
- name: Extract version and set up variables
shell: bash
run: |
VERSION=$(cabal run exe:kda -- --version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "ARCHIVE_DIR=kda-tool-$VERSION" >> $GITHUB_ENV
echo "ARCHIVE_NAME=kda-tool-$VERSION-${{matrix.os}}" >> $GITHUB_ENV
- name: Prepare release artifact
shell: bash
run: |
OUTPUT_DIR=artifacts/$ARCHIVE_DIR
mkdir -p $OUTPUT_DIR
cp $(cabal list-bin kda) $OUTPUT_DIR
cp CHANGELOG.md $OUTPUT_DIR
cp README.md $OUTPUT_DIR
cp LICENSE $OUTPUT_DIR
- name: Strip binary
shell: bash
run: strip artifacts/$ARCHIVE_DIR/kda
- name: Build release archive
shell: bash
run: |
cd artifacts
tar czf $ARCHIVE_NAME.tar.gz $ARCHIVE_DIR
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: release-arch-${{matrix.os}}
retention-days: 1
path: artifacts/*.tar.gz
merge:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download All artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
pattern: release-arch-*
merge-multiple: true
- name: Compute Cheksums
shell: bash
run: |
cd artifacts
sha256sum * > SHA256SUMS
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: releases
retention-days: 30
path: artifacts/*.tar.gz