ci: add Gitea Actions workflow to build and release binaries

This commit is contained in:
2026-05-24 19:03:26 +02:00
parent d06a0d36ba
commit fd4a169db7
3 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
name: Release Binaries
on:
release:
types: [published]
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
image: ocaml/opam:ubuntu-22.04-ocaml-5.4
runner: linux-amd64
static: ""
upx_install: "sudo apt install -y upx"
- arch: arm64
platform: linux/arm64
image: ocaml/opam:alpine-ocaml-5.4
runner: linux-arm64
static: "OCAMLPARAM='_,ccopt=-static,cclib=-static'"
upx_install: "sudo apk add upx"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build (${{ matrix.arch }})
run: |
set -o pipefail
# Crea il container senza avviarlo
CID=$(docker create \
--platform ${{ matrix.platform }} \
-w /src \
${{ matrix.image }} \
sleep infinity)
# Copia i sorgenti dentro con docker cp (funziona anche in DinD)
docker cp "${{ github.workspace }}/." "$CID:/src"
# Avvia ed esegui la build
docker start "$CID"
docker exec "$CID" bash -c "
${{ matrix.upx_install }}
sudo chown -R opam:opam /src
opam update
opam install . --deps-only -y --no-depexts
${{ matrix.static }} opam exec -- dune build @install --release
opam exec -- dune install --prefix /src/dist
upx /src/dist/bin/ical2rem
" 2>&1 | cat
# Copia il binario fuori
docker cp "$CID:/src/dist/bin/ical2rem" \
"${{ github.workspace }}/ical2rem-linux-${{ matrix.arch }}"
docker rm -f "$CID"
- name: Carica artefatto sulla release
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ github.event.release.id }}
run: |
FILENAME="ical2rem-linux-${{ matrix.arch }}"
curl -s -X POST \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${FILENAME}"

View File

@@ -31,8 +31,12 @@
(= 3.1.0))
(ppx_deriving
(= 6.1.1))
(cmdliner
(= 2.1.1))
(icalendar
(= 0.1.13))
(dune-build-info
(>= 3))
(dune
(and
:dev

View File

@@ -14,7 +14,9 @@ depends: [
"timedesc-tzdb" {= "3.1.0"}
"timedesc-tzlocal" {= "3.1.0"}
"ppx_deriving" {= "6.1.1"}
"cmdliner" {= "2.1.1"}
"icalendar" {= "0.1.13"}
"dune-build-info" {>= "3"}
"dune" {>= "3.23" & dev & = "3.23.1"}
"ocamlformat" {dev & = "0.29.0"}
"ocaml-lsp-server" {dev & = "1.26.0"}