Files
claudia-docs-cli/.gitea/workflows/release.yml
Daniel Arroyo cad1b25c03
Some checks failed
Release / build (, amd64, darwin) (push) Successful in 54s
Release / build (, amd64, linux) (push) Successful in 55s
Release / build (, arm64, darwin) (push) Successful in 51s
Release / build (, arm64, linux) (push) Successful in 57s
Release / release (push) Failing after 18s
aaa
2026-03-31 10:32:30 -03:00

202 lines
5.5 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: false
type: string
env:
BINARY_NAME: claudia-docs
GO_VERSION: '1.22'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
ext: ''
- goos: linux
goarch: arm64
ext: ''
- goos: darwin
goarch: amd64
ext: ''
- goos: darwin
goarch: arm64
ext: ''
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Get version
id: version
run: |
if [ -n "${{ gitea.event.inputs.version }}" ]; then
VERSION="${{ gitea.event.inputs.version }}"
else
VERSION="${{ gitea.ref_name }}"
fi
echo "version=${VERSION#v}" >> $GITEA_OUTPUT
echo "tag=${VERSION}" >> $GITEA_OUTPUT
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
BINARY="${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
mkdir -p dist
go build \
-ldflags="-w -s \
-X main.version=${{ steps.version.outputs.version }} \
-X main.commit=$(git rev-parse --short HEAD) \
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o "dist/${BINARY}" \
./cmd/claudia-docs
- name: Package
run: |
cd dist
BINARY="${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
case "${{ matrix.goos }}" in
windows)
zip "${BINARY%.exe}.zip" "${BINARY}"
;;
*)
tar -czf "${BINARY}.tar.gz" "${BINARY}"
;;
esac
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*
retention-days: 5
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(gitea.ref, 'refs/tags/v') || gitea.event.inputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
if [ -n "${{ gitea.event.inputs.version }}" ]; then
VERSION="${{ gitea.event.inputs.version }}"
else
VERSION="${{ gitea.ref_name }}"
fi
echo "version=${VERSION#v}" >> $GITEA_OUTPUT
echo "tag=${VERSION}" >> $GITEA_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: dist/
# ← sin merge-multiple, quedan en subdirectorios:
# dist/linux-amd64/claudia-docs-linux-amd64.tar.gz
# dist/windows-amd64/claudia-docs-windows-amd64.zip
# etc.
- name: Mover artefactos a dist/
run: |
# Mover todos los archivos de subdirectorios a dist/
find dist/ -mindepth 2 -type f -exec mv {} dist/ \;
# Borrar subdirectorios con rm -rf en vez de find -delete
for dir in dist/*/; do
rm -rf "$dir"
done
ls -lh dist/
- name: Generate checksums
run: |
cd dist
sha256sum *.tar.gz > checksums.txt
# Agregar zips solo si existen
ls *.zip 2>/dev/null && sha256sum *.zip >> checksums.txt || true
cat checksums.txt
- name: Generate checksums
run: |
cd dist
sha256sum *.tar.gz *.zip > checksums.txt
cat checksums.txt
- name: Generate install script
run: |
cat > install.sh << 'INSTALL_SCRIPT'
#!/bin/bash
set -e
VERSION="${VERSION:-latest}"
BINARY="claudia-docs"
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
esac
URL="https://gitea.danielarroyo.cl/proyectos/claudia-docs-cli/releases/download/${VERSION}/claudia-docs-${OS}-${ARCH}.tar.gz"
echo "Installing Claudia Docs CLI ${VERSION}..."
echo "Downloading from: ${URL}"
curl -fsSL "${URL}" | tar -xz
chmod +x "${BINARY}-${OS}-${ARCH}"
mv "${BINARY}-${OS}-${ARCH}" "${BINARY}"
if [ -w /usr/local/bin ]; then
mv "${BINARY}" /usr/local/bin/
echo "Installed to /usr/local/bin/claudia-docs"
else
echo "Run: sudo mv ${BINARY} /usr/local/bin/"
fi
echo "Done! Run: claudia-docs --version"
INSTALL_SCRIPT
chmod +x install.sh
- name: Create Release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ steps.version.outputs.tag }}
name: "Claudia Docs CLI ${{ steps.version.outputs.tag }}"
body_path: changelog.md
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
install.sh