Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cad1b25c03 | |||
| 88a659fb03 | |||
| b31d08c35d | |||
| 65293d0961 | |||
| f9464c9def | |||
|
|
b6df678845 | ||
| 0d23a8b8b0 |
@@ -18,8 +18,6 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: golang:1.22-alpine
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -30,9 +28,6 @@ jobs:
|
|||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
ext: ''
|
ext: ''
|
||||||
- goos: windows
|
|
||||||
goarch: amd64
|
|
||||||
ext: '.exe'
|
|
||||||
- goos: darwin
|
- goos: darwin
|
||||||
goarch: amd64
|
goarch: amd64
|
||||||
ext: ''
|
ext: ''
|
||||||
@@ -46,12 +41,22 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Get version
|
- name: Get version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ github.event.inputs.version || github.ref_name }}
|
if [ -n "${{ gitea.event.inputs.version }}" ]; then
|
||||||
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
|
VERSION="${{ gitea.event.inputs.version }}"
|
||||||
echo "tag=$VERSION" >> $GITHUB_OUTPUT
|
else
|
||||||
|
VERSION="${{ gitea.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "version=${VERSION#v}" >> $GITEA_OUTPUT
|
||||||
|
echo "tag=${VERSION}" >> $GITEA_OUTPUT
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
@@ -59,34 +64,32 @@ jobs:
|
|||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
run: |
|
run: |
|
||||||
BINARY="{{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
|
BINARY="${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
go build -ldflags="\
|
go build \
|
||||||
-w -s \
|
-ldflags="-w -s \
|
||||||
-X main.version=${{ steps.version.outputs.version }} \
|
-X main.version=${{ steps.version.outputs.version }} \
|
||||||
-X main.commit=$(git rev-parse --short HEAD) \
|
-X main.commit=$(git rev-parse --short HEAD) \
|
||||||
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||||
-o "dist/${BINARY}" \
|
-o "dist/${BINARY}" \
|
||||||
./cmd/claudia-docs
|
./cmd/claudia-docs
|
||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
BINARY="{{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
|
BINARY="${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
|
||||||
|
|
||||||
case "${{ matrix.goos }}" in
|
case "${{ matrix.goos }}" in
|
||||||
windows)
|
windows)
|
||||||
apk add --no-cache zip
|
zip "${BINARY%.exe}.zip" "${BINARY}"
|
||||||
zip "${BINARY}.zip" "${BINARY}"
|
|
||||||
;;
|
;;
|
||||||
darwin|linux)
|
*)
|
||||||
tar -czf "${BINARY}.tar.gz" "${BINARY}"
|
tar -czf "${BINARY}.tar.gz" "${BINARY}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.goos }}-${{ matrix.goarch }}
|
name: ${{ matrix.goos }}-${{ matrix.goarch }}
|
||||||
path: dist/*
|
path: dist/*
|
||||||
@@ -95,14 +98,9 @@ jobs:
|
|||||||
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 != ''
|
if: startsWith(gitea.ref, 'refs/tags/v') || gitea.event.inputs.version != ''
|
||||||
container:
|
|
||||||
image: alpine:3.19
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup
|
|
||||||
run: apk add --no-cache git curl
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -111,34 +109,45 @@ jobs:
|
|||||||
- name: Get version
|
- name: Get version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ github.event.inputs.version || github.ref_name }}
|
if [ -n "${{ gitea.event.inputs.version }}" ]; then
|
||||||
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
|
VERSION="${{ gitea.event.inputs.version }}"
|
||||||
echo "tag=$VERSION" >> $GITHUB_OUTPUT
|
else
|
||||||
|
VERSION="${{ gitea.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "version=${VERSION#v}" >> $GITEA_OUTPUT
|
||||||
|
echo "tag=${VERSION}" >> $GITEA_OUTPUT
|
||||||
|
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: dist/
|
path: dist/
|
||||||
merge-multiple: true
|
# ← 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: Generate changelog
|
- name: Mover artefactos a dist/
|
||||||
id: changelog
|
|
||||||
run: |
|
run: |
|
||||||
PREV_TAG=$(git tag --sort=-version:refname | sed -n '2p')
|
# Mover todos los archivos de subdirectorios a dist/
|
||||||
if [ -z "$PREV_TAG" ]; then
|
find dist/ -mindepth 2 -type f -exec mv {} dist/ \;
|
||||||
echo "# Changes (full history)" > changelog.md
|
# Borrar subdirectorios con rm -rf en vez de find -delete
|
||||||
git log --pretty=format:"- %s (%h)" -20 >> changelog.md
|
for dir in dist/*/; do
|
||||||
else
|
rm -rf "$dir"
|
||||||
echo "# Changes since ${PREV_TAG}" > changelog.md
|
done
|
||||||
git log "${PREV_TAG}..${{ steps.version.outputs.tag }}" \
|
ls -lh dist/
|
||||||
--pretty=format="- %s (%h)" >> changelog.md
|
|
||||||
fi
|
|
||||||
cat changelog.md
|
|
||||||
|
|
||||||
- name: Generate checksums
|
- name: Generate checksums
|
||||||
run: |
|
run: |
|
||||||
cd dist
|
cd dist
|
||||||
sha256sum * > checksums.txt
|
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
|
cat checksums.txt
|
||||||
|
|
||||||
- name: Generate install script
|
- name: Generate install script
|
||||||
@@ -146,45 +155,36 @@ jobs:
|
|||||||
cat > install.sh << 'INSTALL_SCRIPT'
|
cat > install.sh << 'INSTALL_SCRIPT'
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
VERSION="${VERSION:-latest}"
|
VERSION="${VERSION:-latest}"
|
||||||
BINARY="claudia-docs"
|
BINARY="claudia-docs"
|
||||||
|
|
||||||
# Detect OS
|
|
||||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||||
ARCH="$(uname -m)"
|
ARCH="$(uname -m)"
|
||||||
|
|
||||||
# Map architecture
|
|
||||||
case "$ARCH" in
|
case "$ARCH" in
|
||||||
x86_64) ARCH="amd64" ;;
|
x86_64) ARCH="amd64" ;;
|
||||||
aarch64|arm64) ARCH="arm64" ;;
|
aarch64|arm64) ARCH="arm64" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Map macOS
|
URL="https://gitea.danielarroyo.cl/proyectos/claudia-docs-cli/releases/download/${VERSION}/claudia-docs-${OS}-${ARCH}.tar.gz"
|
||||||
[ "$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 "Installing Claudia Docs CLI ${VERSION}..."
|
||||||
echo "Downloading from: ${URL}"
|
echo "Downloading from: ${URL}"
|
||||||
|
|
||||||
curl -fsSL "${URL}" -o "${BINARY}" || {
|
curl -fsSL "${URL}" | tar -xz
|
||||||
echo "Error: Failed to download binary"
|
|
||||||
exit 1
|
chmod +x "${BINARY}-${OS}-${ARCH}"
|
||||||
}
|
mv "${BINARY}-${OS}-${ARCH}" "${BINARY}"
|
||||||
|
|
||||||
chmod +x "${BINARY}"
|
|
||||||
|
|
||||||
# Install
|
|
||||||
if [ -w /usr/local/bin ]; then
|
if [ -w /usr/local/bin ]; then
|
||||||
mv "${BINARY}" /usr/local/bin/
|
mv "${BINARY}" /usr/local/bin/
|
||||||
echo "Installed to /usr/local/bin/claudia-docs"
|
echo "Installed to /usr/local/bin/claudia-docs"
|
||||||
else
|
else
|
||||||
echo "Installed to ./claudia-docs (not in PATH)"
|
echo "Run: sudo mv ${BINARY} /usr/local/bin/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done!"
|
echo "Done! Run: claudia-docs --version"
|
||||||
INSTALL_SCRIPT
|
INSTALL_SCRIPT
|
||||||
chmod +x install.sh
|
chmod +x install.sh
|
||||||
|
|
||||||
@@ -199,13 +199,4 @@ jobs:
|
|||||||
dist/*.tar.gz
|
dist/*.tar.gz
|
||||||
dist/*.zip
|
dist/*.zip
|
||||||
dist/checksums.txt
|
dist/checksums.txt
|
||||||
install.sh
|
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"
|
|
||||||
13
cmd/claudia-docs/main.go
Normal file
13
cmd/claudia-docs/main.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/claudia/docs-cli/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := cobra.Execute(); err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user