name: helmd-release # På push till master som rör helmd/: testa, bygg linux x64 (+arm64) # och publicera på den rullande releasen "helmd-latest". on: push: branches: [master, main] paths: - "helmd/**" - ".gitea/workflows/helmd-release.yaml" workflow_dispatch: {} jobs: build-release: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Installera Go uses: actions/setup-go@v5 with: go-version: "1.24" cache: false - name: Testa + bygg run: | set -e cd helmd VERSION="latest-$(git rev-parse --short HEAD)" go vet ./... go test ./... mkdir -p build CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath \ -ldflags "-s -w -X main.version=$VERSION" -o build/helmd-linux-x64 . CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath \ -ldflags "-s -w -X main.version=$VERSION" -o build/helmd-linux-arm64 . (cd build && sha256sum helmd-linux-* > checksums.txt && ls -la) - name: Skapa/uppdatera release + ladda upp binärer env: API: http://gitea-d:3000/api/v1 REPO: ${{ github.repository }} TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -e TAG="helmd-latest" BODY="helmd - agent-helm-servern (Go, enskild binär). Rullande bygge från senaste master. Commit: ${{ github.sha }}. Arkitekturer: linux x64 + arm64." rid=$(curl -s -X POST "$API/repos/$REPO/releases" \ -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"$BODY\"}" | jq -r '.id // empty') [ -z "$rid" ] && rid=$(curl -s "$API/repos/$REPO/releases/tags/$TAG" \ -H "Authorization: token $TOKEN" | jq -r '.id') echo "release id $rid" for f in helmd-linux-x64 helmd-linux-arm64 checksums.txt; do aid=$(curl -s "$API/repos/$REPO/releases/$rid/assets" \ -H "Authorization: token $TOKEN" | jq -r ".[] | select(.name==\"$f\") | .id") if [ -n "$aid" ] && [ "$aid" != "null" ]; then curl -s -X DELETE "$API/repos/$REPO/releases/$rid/assets/$aid" \ -H "Authorization: token $TOKEN" -o /dev/null fi curl -s -X POST "$API/repos/$REPO/releases/$rid/assets?name=$f" \ -H "Authorization: token $TOKEN" \ -F "attachment=@helmd/build/$f" -o /dev/null -w " $f -> HTTP %{http_code}\n" done