ci: add Gitea release workflow for AMD64/ARM64 binaries
All checks were successful
All checks were successful
Builds the Go binary on dedicated amd64/arm64 runners via Docker and uploads both artifacts to the Gitea release.
This commit is contained in:
69
.gitea/workflows/release.yml
Normal file
69
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
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
|
||||
|
||||
- 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" sh -c "
|
||||
${{ matrix.upx_install }}
|
||||
export CGO_ENABLED=0
|
||||
go build -trimpath -ldflags='-s -w' -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}"
|
||||
Reference in New Issue
Block a user