Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17c9393b98 | ||
| 4eb68008b3 | |||
| 4258feab81 | |||
| fa6c44fcf1 | |||
| 3a50eac98e |
@@ -3,80 +3,42 @@ name: Release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*' # Se activa solo con tags como v1.0.0, v2.1.3, etc.
|
- '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
|
||||||
|
container:
|
||||||
|
image: golang:1.22-alpine
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
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:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0 # necesario para git describe
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.22'
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
- name: Compilar
|
|
||||||
env:
|
|
||||||
GOOS: ${{ matrix.goos }}
|
|
||||||
GOARCH: ${{ matrix.goarch }}
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
run: |
|
|
||||||
# Nombre del binario: app-linux-amd64, app-windows-amd64.exe, etc.
|
|
||||||
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
|
|
||||||
|
|
||||||
go build \
|
|
||||||
-ldflags="-w -s \
|
|
||||||
-X main.version=${{ gitea.ref_name }} \
|
|
||||||
-X main.commit=${{ gitea.sha }} \
|
|
||||||
-X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
||||||
-o "dist/${BINARY_NAME}" \
|
|
||||||
./cmd/main.go
|
|
||||||
|
|
||||||
- name: Comprimir artefacto
|
|
||||||
run: |
|
|
||||||
cd dist
|
|
||||||
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
|
|
||||||
|
|
||||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
|
||||||
zip "${BINARY_NAME%.exe}.zip" "${BINARY_NAME}"
|
|
||||||
else
|
|
||||||
tar -czf "${BINARY_NAME}.tar.gz" "${BINARY_NAME}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Subir artefacto temporal
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: bin-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
||||||
path: dist/*.tar.gz
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build # espera que todos los builds terminen
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -84,44 +46,166 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Descargar todos los 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: 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)
|
||||||
|
apk add --no-cache zip
|
||||||
|
zip "${BINARY}.zip" "${BINARY}"
|
||||||
|
;;
|
||||||
|
darwin|linux)
|
||||||
|
tar -czf "${BINARY}.tar.gz" "${BINARY}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
|
path: dist/*
|
||||||
|
retention-days: 5
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.version != ''
|
||||||
|
container:
|
||||||
|
image: alpine:3.19
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup
|
||||||
|
run: apk add --no-cache git curl
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- 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 desde commits
|
- name: Generate changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
run: |
|
run: |
|
||||||
# Obtener tag anterior
|
|
||||||
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
|
||||||
CHANGES=$(git log --pretty=format:"- %s (%h)" | head -20)
|
echo "# Changes (full history)" > changelog.md
|
||||||
|
git log --pretty=format:"- %s (%h)" -20 >> changelog.md
|
||||||
else
|
else
|
||||||
CHANGES=$(git log "${PREV_TAG}..${{ gitea.ref_name }}" \
|
echo "# Changes since ${PREV_TAG}" > changelog.md
|
||||||
--pretty=format:"- %s (%h)")
|
git log "${PREV_TAG}..${{ steps.version.outputs.tag }}" \
|
||||||
|
--pretty=format="- %s (%h)" >> changelog.md
|
||||||
fi
|
fi
|
||||||
|
cat changelog.md
|
||||||
# Guardar en archivo para el siguiente paso
|
|
||||||
echo "${CHANGES}" > changelog.txt
|
|
||||||
echo "prev_tag=${PREV_TAG}" >> $GITEA_OUTPUT
|
|
||||||
|
|
||||||
- name: Crear checksums
|
- name: Generate checksums
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
sha256sum *.tar.gz *.zip 2>/dev/null > checksums.txt || \
|
sha256sum * > checksums.txt
|
||||||
sha256sum *.tar.gz > checksums.txt
|
|
||||||
cat checksums.txt
|
cat checksums.txt
|
||||||
|
|
||||||
- name: Crear Release en Gitea
|
- 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/*.zip
|
dist/*.zip
|
||||||
dist/checksums.txt
|
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"
|
||||||
|
|||||||
Reference in New Issue
Block a user