feat: Improve release workflow with install script, checksums and better packaging
Some checks failed
Release / build (, amd64, darwin) (push) Failing after 12s
Release / build (, amd64, linux) (push) Failing after 10s
Release / build (, arm64, darwin) (push) Failing after 9s
Release / build (, arm64, linux) (push) Failing after 9s
Release / build (.exe, amd64, windows) (push) Failing after 10s
Release / release (push) Has been skipped
Release / latest (push) Has been skipped

This commit is contained in:
Claudia CLI Bot
2026-03-31 05:16:06 +00:00
parent 4eb68008b3
commit 17c9393b98

View File

@@ -4,11 +4,20 @@ on:
push: push:
tags: tags:
- 'v*' - '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: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
# ← cada job corre dentro de esta imagen
container: container:
image: golang:1.22-alpine image: golang:1.22-alpine
@@ -17,106 +26,186 @@ jobs:
include: include:
- goos: linux - goos: linux
goarch: amd64 goarch: amd64
suffix: "" ext: ''
- goos: linux - goos: linux
goarch: arm64 goarch: arm64
suffix: "" ext: ''
- goos: windows - goos: windows
goarch: amd64 goarch: amd64
suffix: ".exe" ext: '.exe'
- goos: darwin - goos: darwin
goarch: amd64 goarch: amd64
suffix: "" ext: ''
- goos: darwin - goos: darwin
goarch: arm64 goarch: arm64
suffix: "" ext: ''
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Compilar - name: Get version
id: version
run: |
VERSION=${{ github.event.inputs.version || github.ref_name }}
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
echo "tag=$VERSION" >> $GITHUB_OUTPUT
- name: Build
env: env:
GOOS: ${{ matrix.goos }} GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }} GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0 CGO_ENABLED: 0
run: | run: |
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}" BINARY="{{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
mkdir -p dist mkdir -p dist
go build \ go build -ldflags="\
-ldflags="-w -s \ -w -s \
-X main.version=${{ gitea.ref_name }} \ -X main.version=${{ steps.version.outputs.version }} \
-X main.commit=${{ gitea.sha }}" \ -X main.commit=$(git rev-parse --short HEAD) \
-o "dist/${BINARY_NAME}" \ -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
./cmd/main.go -o "dist/${BINARY}" \
./cmd/claudia-docs
- name: Comprimir - name: Package
run: | run: |
cd dist cd dist
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}" BINARY="{{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
apk add --no-cache zip case "${{ matrix.goos }}" in
zip "${BINARY_NAME%.exe}.zip" "${BINARY_NAME}" windows)
else apk add --no-cache zip
tar -czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}" zip "${BINARY}.zip" "${BINARY}"
fi ;;
darwin|linux)
tar -czf "${BINARY}.tar.gz" "${BINARY}"
;;
esac
- name: Subir artefacto temporal - name: Upload artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: bin-${{ matrix.goos }}-${{ matrix.goarch }} name: ${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*.tar.gz path: dist/*
retention-days: 1 retention-days: 5
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs: build
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != ''
container: container:
image: alpine:3.19 image: alpine:3.19
steps: steps:
- name: Instalar dependencias - name: Setup
run: apk add --no-cache git run: apk add --no-cache git curl
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Descargar artefactos - name: Get version
id: version
run: |
VERSION=${{ github.event.inputs.version || github.ref_name }}
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
echo "tag=$VERSION" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
path: dist/ path: dist/
merge-multiple: true merge-multiple: true
- name: Generar changelog - name: Generate changelog
id: changelog
run: | run: |
PREV_TAG=$(git tag --sort=-version:refname | sed -n '2p') PREV_TAG=$(git tag --sort=-version:refname | sed -n '2p')
if [ -z "$PREV_TAG" ]; then if [ -z "$PREV_TAG" ]; then
git log --pretty=format:"- %s (%h)" | head -20 > changelog.txt echo "# Changes (full history)" > changelog.md
git log --pretty=format:"- %s (%h)" -20 >> changelog.md
else else
git log "${PREV_TAG}..${{ gitea.ref_name }}" \ echo "# Changes since ${PREV_TAG}" > changelog.md
--pretty=format:"- %s (%h)" > changelog.txt git log "${PREV_TAG}..${{ steps.version.outputs.tag }}" \
--pretty=format="- %s (%h)" >> changelog.md
fi fi
cat changelog.txt cat changelog.md
- name: Crear checksums - name: Generate checksums
run: | run: |
cd dist cd dist
sha256sum * > checksums.txt sha256sum * > checksums.txt
cat checksums.txt cat checksums.txt
- name: Crear Release - name: Generate install script
run: |
cat > install.sh << 'INSTALL_SCRIPT'
#!/bin/bash
set -e
VERSION="${VERSION:-latest}"
BINARY="claudia-docs"
# Detect OS
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
# Map architecture
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
esac
# Map macOS
[ "$OS" = "darwin" ] && OS="darwin"
# Download
URL="https://gitea.danielarroyo.cl/proyectos/claudia-docs-cli/releases/download/${VERSION}/claudia-docs-${OS}-${ARCH}"
echo "Installing Claudia Docs CLI ${VERSION}..."
echo "Downloading from: ${URL}"
curl -fsSL "${URL}" -o "${BINARY}" || {
echo "Error: Failed to download binary"
exit 1
}
chmod +x "${BINARY}"
# Install
if [ -w /usr/local/bin ]; then
mv "${BINARY}" /usr/local/bin/
echo "Installed to /usr/local/bin/claudia-docs"
else
echo "Installed to ./claudia-docs (not in PATH)"
fi
echo "Done!"
INSTALL_SCRIPT
chmod +x install.sh
- name: Create Release
uses: https://gitea.com/actions/gitea-release-action@v1 uses: https://gitea.com/actions/gitea-release-action@v1
with: with:
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
tag_name: ${{ gitea.ref_name }} tag_name: ${{ steps.version.outputs.tag }}
name: "Release ${{ gitea.ref_name }}" name: "Claudia Docs CLI ${{ steps.version.outputs.tag }}"
body_path: changelog.txt body_path: changelog.md
files: | files: |
dist/*.tar.gz dist/*.tar.gz
dist/checksums.txt dist/*.zip
dist/checksums.txt
install.sh
latest:
runs-on: ubuntu-latest
needs: release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Update latest tag
run: |
echo "Latest release updated"