-
-
Notifications
You must be signed in to change notification settings - Fork 0
254 lines (223 loc) · 8.45 KB
/
main.yaml
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: main
env:
LANG: C.UTF-8
GH_TOKEN: ${{ github.token }}
on:
push:
branches: main
pull_request:
branches: main
permissions:
contents: write
packages: write
jobs:
#linux:
# name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-24.04]
# platform: ['x86_64-linux']
# ghc-version: ['9.6.6']
# cabal-version: ['3.12.1.0']
# steps:
# - uses: actions/checkout@v4
# # Following https://github.com/docker/build-push-action?tab=readme-ov-file#usage
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ github.token }}
# - name: Cache
# uses: actions/cache@v4
# id: cache
# with:
# path: |
# root-local-state-cabal-store
# root-cache-cabal
# dist-newstyle
# key: plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
# - name: Inject cache into docker
# uses: reproducible-containers/[email protected]
# with:
# cache-map: |
# {
# "root-local-state-cabal-store": "/root/.local/state/cabal/store",
# "root-cache-cabal": "/root/.cache/cabal",
# "dist-newstyle": "dist-newstyle"
# }
# skip-extraction: ${{ steps.cache.outputs.cache-hit }}
# - name: Build and test
# uses: docker/build-push-action@v6
# with:
# context: .
# pull: true
# # XXX: don't push feature branches either?
# push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
# file: Dockerfile
# tags: |
# ghcr.io/spex-lang/spex-build:${{ github.ref_name }}
# ghcr.io/spex-lang/spex-build:latest
# # We pass in the version as a secret, since they don't affect the
# # container caching, this will be picked up and used by --version.
# # https://docs.docker.com/build/building/secrets/
# secrets: version=${{ github.sha }}
# # https://docs.docker.com/build/ci/github-actions/cache/#github-cache
# # https://docs.docker.com/build/ci/github-actions/cache/#cache-mounts
# cache-from: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache
# cache-to: type=registry,ref=ghcr.io/spex-lang/spex-build:buildcache,mode=max
# - name: Create new git tag, if merge to main and .cabal version is bumped
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
# uses: sol/haskell-autotag@v1
# id: autotag
# - name: Build static binaries
# if: steps.autotag.outputs.created
# uses: docker/build-push-action@v6
# with:
# context: .
# pull: true
# push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs.
# file: release/Dockerfile
# tags: |
# ghcr.io/spex-lang/spex:${{ github.ref_name }}
# ghcr.io/spex-lang/spex:latest
# outputs: type=local,dest=${{ github.workspace }}/bin/
# # https://docs.docker.com/build/ci/github-actions/cache/#github-cache
# cache-from: type=registry,ref=ghcr.io/spex-lang/spex:buildcache
# cache-to: type=registry,ref=ghcr.io/spex-lang/spex:buildcache,mode=max
# - name: Release
# if: steps.autotag.outputs.created
# run: |
# ls -R bin/
# find bin/ -maxdepth 1 -type f -executable -exec \
# mv {} "{}-${{ steps.autotag.outputs.version }}-${{ matrix.platform }}" \;
# gh release create --draft --notes-file=CHANGELOG.md \
# "v${{ steps.autotag.outputs.version }}" ${{ github.workspace }}/bin/*
#
build:
name: Build on ${{ matrix.os }} using GHC ${{ matrix.ghc-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
#os: [ubuntu-24.04, macos-15, windows-2022]
os: [windows-2022]
ghc-version: ['9.6.6']
cabal-version: ['3.12.1.0']
env:
platform: ${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-linux' ||
startsWith(matrix.os, 'macos') && 'arm64-macos' ||
startsWith(matrix.os, 'windows') && 'x86_64-windows' }}
outputs:
new-version: ${{ steps.version-bump.outputs.new-version }}
steps:
- uses: actions/checkout@v4
- name: Set up GHC ${{ matrix.ghc-version }} (MacOS and Windows only)
if: ${{ env.platform != 'x86_64-linux' }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
cabal-version: ${{ matrix.cabal-version }}
cabal-update: false
#- name: Install make (Windows only)
# if: ${{ env.platform == 'x86_64-windows' }}
# run: |
# choco install make
## Use Alpine container to get static binaries on Linux.
#- name: Login to GitHub Container Registry (Linux only)
# if: ${{ env.platform == 'x86_64-linux' }}
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ github.token }}
#- name: Pull image (Linux only)
# if: ${{ env.platform == 'x86_64-linux' }}
# run: make pull-image
#- name: Build image (Linux only)
# if: ${{ env.platform == 'x86_64-linux' }}
# run: make build-image
#- name: Push image (Linux only)
# if: ${{ env.platform == 'x86_64-linux' }}
# run: make push-image
#- name: Restore cached dependencies
# uses: actions/cache/restore@v4
# id: cache
# env:
# key: ${{ runner.os }}-ghc-${{ matrix.ghc-version }}-cabal-${{ matrix.cabal-version }}
# with:
# path: |
# ${HOME}/.cache/cabal
# ${HOME}/.cabal/store
# dist-newstyle
# key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
# restore-keys: ${{ env.key }}-plan-
#- name: Build dependencies
# if: steps.cache.outputs.cache-hit != 'true'
# run: make build-deps
## Cache dependencies already here, so that we do not have to rebuild them
## should the subsequent steps fail.
#- name: Save cached dependencies
# uses: actions/cache/save@v4
# if: steps.cache.outputs.cache-hit != 'true'
# with:
# path: |
# ${HOME}/.cache/cabal
# ${HOME}/.cabal/store
# dist-newstyle
# key: ${{ steps.cache.outputs.cache-primary-key }}
#- name: Build
# env:
# SPEX_GIT_COMMIT: ${{ github.sha }}
# run: make build
#- name: Test
# run: make test
- name: Check for version bump
id: version-bump
run: | # make bump
echo "new-version=0.0.0 >> $env:GITHUB_OUTPUT
- name: Install binaries
# Only if there's a version bump and we are merging to main, i.e
# exclude PRs.
#if: ${{ steps.version-bump.outputs.new-version != '' &&
# github.event_name == 'push' &&
# github.ref == 'refs/heads/main' }}
id: install
env:
SPEX_GIT_COMMIT: ${{ github.sha }}
run: |
echo ${{ steps.version-bump.outputs.new-version }}
echo ${{ steps.version-bump.outputs.new-version != '' }}
# make install
#- name: Upload binary artifacts
# if: steps.install.outcome == 'success'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.platform }}
# path: bin/*
#release:
# name: Create release
# runs-on: ubuntu-latest
# needs: [build]
# if: ${{ needs.build.outputs.new-version }}
# steps:
# - uses: actions/checkout@v4
# with:
# sparse-checkout: |
# spex.cabal
# Makefile
# CHANGELOG.md
# sparse-checkout-cone-mode: false
# - name: Download binary artifacts
# uses: actions/download-artifact@v4
# with:
# path: bin
# - name: Compress binaries and create release
# env:
# NEW_VERSION: ${{ needs.build.outputs.new-version }}
# run: make release