-
-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (172 loc) · 6.19 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
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/buildkit-cache-dance@v3.1.0
# 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/*
#
arm64-macos-binary:
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15]
platform: ['arm64-macos']
ghc-version: ['9.6.6']
cabal-version: ['3.12.1.0']
outputs:
new-version: ${{ steps.version-bump.outputs.new-version }}
steps:
- uses: actions/checkout@v4
- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
cabal-version: ${{ matrix.cabal-version }}
cabal-update: true
- name: Build dependencies
run: make build-deps
- name: Build
run: make build
- name: Test
run: make test
- name: Check for version bump
id: version-bump
run: make bump
- 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:
NEW_VERSION: ${{ steps.version-bump.outputs.new-version }}
run: make install
- name: Upload binary artifacts
if: steps.install.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: spex-${{ matrix.platform }}
path: bin/*
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [arm64-macos-binary]
if: ${{ needs.arm64-macos-binary.outputs.new-version }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
Makefile
CHANGELOG.md
sparse-checkout-cone-mode: false
- name: Download binary artifacts
uses: actions/download-artifact@v4
with:
path: bin
pattern: spex-*
merge-multiple: true
- name: Install upx
run: |
sudo apt-get update
sudo apt-get install upx-ucl
- name: Compress binaries and create release
env:
NEW_VERSION: ${{ needs.arm64-macos-binary.outputs.new-version }}
run: make release