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: golang:1.24-alpine runner: linux-amd64 upx_install: "apk add --no-cache upx" - arch: arm64 platform: linux/arm64 image: golang:1.24-alpine runner: linux-arm64 upx_install: "apk add --no-cache upx zstd-static" steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Build (${{ matrix.arch }}) run: | set -o pipefail VERSION="$(git describe --tags --always --dirty)" echo "Version: $VERSION" # 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" sh -c " ${{ matrix.upx_install }} export CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X main.version=$VERSION' -o /src/dist/todotxt2remind . upx /src/dist/todotxt2remind " 2>&1 | cat # Copia il binario fuori docker cp "$CID:/src/dist/todotxt2remind" \ "${{ github.workspace }}/todotxt2remind-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="todotxt2remind-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}"