Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 73 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,99 @@ name: Release
on:
release:
types: [published]

workflow_dispatch:
inputs:
tag:
description: 'Tag to build (optional)'
description: "Tag to build (optional)"
required: false
default: ''
default: ""

permissions: read-all
permissions:
contents: write

jobs:
build:
name: Build ${{ matrix.platform }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
include:
- os: ubuntu-latest
platform: linux-x86_64
binary_ext: ""
- os: macos-latest
platform: darwin-arm64
binary_ext: ""
- os: windows-latest
platform: windows-x86_64
binary_ext: ".exe"
fail-fast: false
runs-on: ${{ matrix.platform }}

runs-on: ${{ matrix.os }}

steps:
- name: Checkout tree
uses: actions/checkout@v4

- name: Extract version from tag
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
if [[ -n "${{ github.event.inputs.tag }}" ]]; then
echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "VERSION=dev-${{ github.sha }}" >> $GITHUB_OUTPUT
fi
else
echo "VERSION=dev-${{ github.sha }}" >> $GITHUB_OUTPUT
fi

- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5

- run: opam install . --deps-only --with-test
- name: Install dependencies
run: opam install . --deps-only --with-test

- name: Build
run: opam exec -- dune build

- run: opam exec -- dune build
- name: Run tests
run: opam exec -- dune runtest

- run: opam exec -- dune runtest

- name: Install
run: opam install . --destdir _install

- name: Prepare binary
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
cp _install/bin/agent-sync.exe agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}
else
cp _install/bin/agent-sync agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}
chmod +x agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}
fi
sha256sum agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }} > agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256

- name: Upload Release Asset
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}
./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Artifacts (Manual Build)
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/')
with:
name: agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}
path: |
./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}
./agent-sync-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.binary_ext }}.sha256
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# ocamlbuild and Dune default working directory
_build/
_install/

# ocamlbuild targets
*.byte
Expand Down
Loading