Skip to content

Commit d249d4b

Browse files
committed
CI: Fix Windows release build
- Use setup-ocaml instead of downloading Opam from scratch. Removes calls to the cygwin installer. - Move scripts into the action file. Allows building for past releases. The script is now small enough to embed.
1 parent 07bf7a2 commit d249d4b

File tree

2 files changed

+34
-82
lines changed

2 files changed

+34
-82
lines changed

.github/workflows/build-mingw64.yml

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,65 @@ on:
99
required: true
1010
default: 'main'
1111

12-
env:
13-
CYGWINSETUP: setup-x86_64.exe
14-
PACKAGES: git,m4,patchutils,make,curl,unzip,mingw64-x86_64-binutils,mingw64-x86_64-gcc-core,mingw64-x86_64-headers,mingw64-x86_64-runtime
15-
SITE: https://mirrors.kernel.org/sourceware/cygwin
16-
1712
jobs:
1813
build:
1914
runs-on: windows-latest
20-
env:
21-
SHELLOPTS: igncr
2215
steps:
23-
- name: Set Build Ref for Release Builds
16+
- name: Set ref for release builds
2417
if: github.event_name == 'release'
2518
run: |
2619
"build_ref=${{ github.ref }}" >> $env:GITHUB_ENV
27-
- name: Set Build Ref for Manual Builds
20+
21+
- name: Set ref for manual builds
2822
if: github.event_name == 'workflow_dispatch'
2923
run: |
3024
"build_ref=${{ github.event.inputs.ref }}" >> $env:GITHUB_ENV
25+
26+
- name: Set artifact name
27+
shell: bash
28+
run: |
29+
echo "artifact_name=ocamlformat-${build_ref##*/}.exe" >> $GITHUB_ENV
30+
3131
- name: Disable Git EOL Conversion
3232
run: |
3333
git config --global core.autocrlf false
34+
3435
- name: Checkout Repository
3536
uses: actions/checkout@v3
3637
with:
3738
ref: ${{ env.build_ref }}
38-
- name: Download Cygwin Installer
39-
run: |
40-
curl.exe -o C:\${{ env.CYGWINSETUP }} https://www.cygwin.com/${{ env.CYGWINSETUP }}
41-
shell: cmd
42-
- name: Setup Cygwin
39+
40+
- uses: ocaml/setup-ocaml@v2
41+
with:
42+
ocaml-compiler: 4.14.x
43+
opam-repositories: |
44+
default: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
45+
opam: https://github.com/ocaml/opam-repository.git
46+
47+
- name: Install dependencies
4348
run: |
44-
C:\${{ env.CYGWINSETUP }} -A -q -D -L -g -o -s ${{ env.SITE }} -l C:\cygwin64-cache -R C:\cygwin64 -C Base -P ${{ env.PACKAGES }}
45-
shell: cmd
46-
- name: Run Build Script
49+
opam pin add -yn ocamlformat-lib.dev .
50+
opam pin add -yn ocamlformat.dev .
51+
opam install -y --deps-only ocamlformat
52+
53+
- name: Build
4754
run: |
48-
cd '${{ github.workspace }}'
49-
git config --global --add safe.directory "$(pwd)"
50-
bash tools/build-mingw64.sh
51-
echo "artifact_name=ocamlformat-$(basename ${{ env.build_ref }}).exe" >> $GITHUB_ENV
52-
shell: C:\cygwin64\bin\bash.exe --login --norc '{0}'
53-
- name: Rename Artifact
55+
opam exec -- dune subst
56+
opam exec -- dune build -p ocamlformat-lib,ocamlformat @install
57+
opam exec -- dune install --prefix=./install ocamlformat
58+
59+
- name: Version check
5460
run: |
55-
Copy-Item ${{ github.workspace }}\_build\install\default\bin\ocamlformat.exe -Destination .\${{ env.artifact_name }}
61+
echo "Version check:"
62+
install/bin/ocamlformat --version
63+
5664
- name: Upload Artifact
5765
uses: actions/upload-artifact@v3
5866
with:
5967
name: ${{ env.artifact_name }}
60-
path: ${{ env.artifact_name }}
68+
path: install/bin/ocamlformat
6169
if-no-files-found: error
70+
6271
- name: Upload Release Asset
6372
if: github.event_name == 'release'
6473
run: >

tools/build-mingw64.sh

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)