Skip to content

Commit

Permalink
gha: add opam binaries artifact generation
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Dec 13, 2023
1 parent 2592c14 commit ddddd0e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,49 @@ let main_build_job ~analyse_job ~cygwin_job ?section runner start_version ~oc ~w
let matrix = ((platform <> Windows), matrix, includes) in
let needs = if platform = Windows then [analyse_job; cygwin_job] else [analyse_job] in
let host = host_of_platform platform in
let upload_binaries =
let cond =
let label =
Predicate (true, Compare ("github.event.label.name", "PR: BINARIES"))
in
match runner with
| MacOS -> label
| Windows ->
And (label,
Predicate (true, EndsWith ("matrix.host", "-pc-cygwin")))
| Linux ->
And (label,
Predicate (true, Compare ("matrix.ocamlv", "4.14.1")))
in
let withs =
let name =
match runner with
| Linux | MacOS ->
Literal ["opam-exe-${{ runner.os }}-${{ matrix.ocamlv }}"]
| Windows ->
Literal
["opam-exe-${{ matrix.host }}-${{ matrix.ocamlv }}-${{ matrix.build }}"]
in
let paths =
let prefix =
match runner with
| MacOS -> "/Users/runner/local/bin/"
| Linux -> "/home/runner/local/bin/"
| Windows -> "D:\\Local\\bin\\"
in
let binaries = ["opam-installer"; "opam"] in
match runner with
| MacOS | Linux ->
Literal ((List.rev_map (fun s -> prefix ^ s)) binaries)
| Windows ->
Literal ((List.rev_map (fun s -> prefix ^ s ^ ".exe"))
("opam-putenv":: binaries))
in
[ "name", name; "path", paths; ]
in
uses "Upload opam binaries" "actions/upload-artifact@v3"
~cond ~withs ~continue_on_error:true
in
job ~oc ~workflow ~runs_on:(Runner [runner]) ?shell ?section ~needs ~matrix ("Build-" ^ name_of_platform platform)
++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"])
++ only_on Windows (git_lf_checkouts ~cond:(Predicate(true, EndsWith("matrix.host", "-pc-cygwin"))) ~shell:"cmd" ~title:"Configure LF checkout for Cygwin" ())
Expand All @@ -338,6 +381,7 @@ let main_build_job ~analyse_job ~cygwin_job ?section runner start_version ~oc ~w
++ only_on Windows (unpack_cygwin "${{ matrix.build }}" "${{ matrix.host }}")
++ build_cache OCaml platform "${{ matrix.ocamlv }}" host
++ run "Build" ["bash -exu .github/scripts/main/main.sh " ^ host]
++ upload_binaries
++ not_on Windows (run "Test (basic)" ["bash -exu .github/scripts/main/test.sh"])
++ only_on Windows (run "Test (basic - Cygwin)" ~cond:(Predicate(true, EndsWith("matrix.host", "-pc-cygwin"))) ["bash -exu .github/scripts/main/test.sh"])
++ only_on Windows (run "Test (basic - native Windows)" ~env:[("OPAMROOT", {|D:\a\opam\opam\.opam|})] ~shell:"cmd" ~cond:(Predicate(false, EndsWith("matrix.host", "-pc-cygwin")))
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ jobs:
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }}
- name: Build
run: bash -exu .github/scripts/main/main.sh x86_64-pc-linux-gnu
- name: Upload opam binaries
if: github.event.label.name == 'PR: BINARIES' && matrix.ocamlv == '4.14.1'
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: opam-exe-${{ runner.os }}-${{ matrix.ocamlv }}
path: |
/home/runner/local/bin/opam
/home/runner/local/bin/opam-installer
- name: Test (basic)
run: bash -exu .github/scripts/main/test.sh

Expand Down Expand Up @@ -204,6 +213,16 @@ jobs:
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }} ${{ matrix.host }}
- name: Build
run: bash -exu .github/scripts/main/main.sh ${{ matrix.host }}
- name: Upload opam binaries
if: github.event.label.name == 'PR: BINARIES' && endsWith(matrix.host, '-pc-cygwin')
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: opam-exe-${{ matrix.host }}-${{ matrix.ocamlv }}-${{ matrix.build }}
path: |
D:\Local\bin\opam.exe
D:\Local\bin\opam-installer.exe
D:\Local\bin\opam-putenv.exe
- name: Test (basic - Cygwin)
if: endsWith(matrix.host, '-pc-cygwin')
run: bash -exu .github/scripts/main/test.sh
Expand Down Expand Up @@ -255,6 +274,15 @@ jobs:
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }}
- name: Build
run: bash -exu .github/scripts/main/main.sh x86_64-apple-darwin
- name: Upload opam binaries
if: github.event.label.name == 'PR: BINARIES'
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: opam-exe-${{ runner.os }}-${{ matrix.ocamlv }}
path: |
/Users/runner/local/bin/opam
/Users/runner/local/bin/opam-installer
- name: Test (basic)
run: bash -exu .github/scripts/main/test.sh

Expand Down

0 comments on commit ddddd0e

Please sign in to comment.