Skip to content

Commit ae075eb

Browse files
committed
Add dune pkg binary release workflow
When a tag is pushed, a github action will build the project using dune package management and release the binaries under the tag on github. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
1 parent 4b57e6d commit ae075eb

99 files changed

Lines changed: 2683 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# The actions/cache github action allows builds of tags to use artifacts cached
2+
# by builds of the default branch, but doesn't allow builds of tags to use
3+
# artifacts cached by other tags. Thus to make the dependencies of the project
4+
# available to the "release" workflow, they are built and cached by this
5+
# workflow.
6+
7+
name: Build and Cache Dependencies
8+
9+
on:
10+
push:
11+
branches:
12+
- 'main'
13+
14+
jobs:
15+
release-unix:
16+
name: Build and cache deps for ${{ matrix.os }}
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
include:
21+
- os: macos-15-intel
22+
- os: macos-15
23+
- os: ubuntu-latest
24+
steps:
25+
26+
- uses: actions/checkout@v4
27+
28+
- uses: ocaml-dune/setup-dune@v0
29+
30+
- name: Cache build artifacts
31+
id: artifact-cache
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
_build
36+
~/.cache/dune
37+
key: ${{ matrix.os }}-artifacts-${{ hashFiles('dune.lock') }}
38+
39+
- name: Build the project
40+
run: dune build @install --release --only-packages container-image

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release-unix:
10+
name: Release for ${{ matrix.name }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: macos-15-intel
16+
name: x86_64-macos
17+
- os: macos-15
18+
name: aarch64-macos
19+
- os: ubuntu-latest
20+
name: x86_64-linux
21+
steps:
22+
23+
- uses: actions/checkout@v6
24+
25+
- uses: ocaml-dune/setup-dune@v0
26+
27+
- name: Load dependencies from the cache
28+
id: artifact-cache
29+
uses: actions/cache/restore@v4
30+
with:
31+
path: |
32+
_build
33+
~/.cache/dune
34+
key: ${{ matrix.os }}-artifacts-${{ hashFiles('dune.lock') }}
35+
36+
- name: Build the project
37+
run: dune build @install --only-packages container-image
38+
39+
- run: echo OUT_NAME=container-image-${{ github.ref_name }}-${{ matrix.name }} >> $GITHUB_ENV
40+
41+
- name: Release a tarball of build outputs
42+
run: |
43+
mkdir -p "$OUT_NAME"
44+
cp -rlf _build/install/default/* "$OUT_NAME"
45+
tar czf "$OUT_NAME.tar.gz" "$OUT_NAME"
46+
47+
- name: Upload assets
48+
uses: ncipollo/release-action@v1
49+
with:
50+
allowUpdates: true
51+
artifacts: "*.tar.gz"
52+
53+
54+
release-x86_64-linux-musl-static:
55+
name: Build for x86_64-linux-musl-static
56+
runs-on: ubuntu-latest
57+
steps:
58+
59+
- uses: actions/checkout@v6
60+
61+
- run: echo OUT_NAME=container-image-${{ github.ref_name }}-x86_64-linux-statically-linked >> $GITHUB_ENV
62+
63+
- run: mkdir -p $OUT_NAME
64+
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
- run: docker buildx build --output type=local,dest=$OUT_NAME -f scripts/build-static.dockerfile .
68+
69+
- name: Test we can execute the exe on the host as a basic sanity check
70+
run: $OUT_NAME/bin/image --help
71+
72+
- name: Make a tarball of build outputs
73+
run: tar czf "$OUT_NAME.tar.gz" "$OUT_NAME"
74+
75+
- name: Upload assets
76+
uses: ncipollo/release-action@v1
77+
with:
78+
allowUpdates: true
79+
artifacts: "*.tar.gz"

bin/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515
fmt.cli
1616
logs.fmt
1717
fmt.tty))
18+
19+
(env
20+
(static
21+
(link_flags
22+
(:standard -cclib -static))))

dune.lock/alcotest.1.9.1.pkg

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(version 1.9.1)
2+
3+
(build
4+
(all_platforms
5+
((action
6+
(progn
7+
(when %{pkg-self:dev} (run dune subst))
8+
(run dune build -p %{pkg-self:name} -j %{jobs} @install))))))
9+
10+
(depends
11+
(all_platforms
12+
(dune ocaml fmt astring cmdliner re stdlib-shims uutf ocaml-syntax-shims)))
13+
14+
(source
15+
(fetch
16+
(url
17+
https://github.com/mirage/alcotest/releases/download/1.9.1/alcotest-1.9.1.tbz)
18+
(checksum
19+
sha256=1e29c3b41d4329062105b723dfda3aff86b8cef5e7c7500d0e491fc5fd78e482)))

dune.lock/angstrom.0.16.1.pkg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(version 0.16.1)
2+
3+
(build
4+
(all_platforms
5+
((action
6+
(progn
7+
(when %{pkg-self:dev} (run dune subst))
8+
(run dune build -p %{pkg-self:name} -j %{jobs}))))))
9+
10+
(depends
11+
(all_platforms
12+
(ocaml dune bigstringaf ocaml-syntax-shims)))
13+
14+
(source
15+
(fetch
16+
(url https://github.com/inhabitedtype/angstrom/archive/0.16.1.tar.gz)
17+
(checksum md5=a9e096b4b2b8e4e3bb17d472bbccaad0)))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(version 0.3.2)
2+
3+
(build
4+
(all_platforms
5+
((action
6+
(progn
7+
(when %{pkg-self:dev} (run dune subst))
8+
(run dune build -p %{pkg-self:name} -j %{jobs}))))))
9+
10+
(depends
11+
(all_platforms
12+
(ocaml dune ptime)))
13+
14+
(source
15+
(fetch
16+
(url
17+
https://github.com/mirleft/ocaml-asn1-combinators/releases/download/v0.3.2/asn1-combinators-0.3.2.tbz)
18+
(checksum
19+
sha256=2b26985f6e2722073dcd9f84355bd6757e12643b5a48e30b3c07ff7cfb0d8a7f)))

dune.lock/astring.0.8.5.pkg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(version 0.8.5)
2+
3+
(build
4+
(all_platforms
5+
((action (run ocaml pkg/pkg.ml build --pinned %{pkg-self:pinned})))))
6+
7+
(depends
8+
(all_platforms
9+
(ocaml ocamlfind ocamlbuild topkg)))
10+
11+
(source
12+
(fetch
13+
(url https://erratique.ch/software/astring/releases/astring-0.8.5.tbz)
14+
(checksum
15+
sha256=865692630c07c3ab87c66cdfc2734c0fdfc9c34a57f8e89ffec7c7d15e7a70fa)))

dune.lock/base-domains.base.pkg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(version base)
2+
3+
(depends
4+
(all_platforms (ocaml)))

dune.lock/base-threads.base.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(version base)

dune.lock/base-unix.base.pkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(version base)

0 commit comments

Comments
 (0)