Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4eb68008b3 | |||
| 4258feab81 | |||
| fa6c44fcf1 | |||
| 3a50eac98e | |||
| edddc538f9 | |||
| 258b1b0a0b |
122
.gitea/workflows/release.yml
Normal file
122
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# ← cada job corre dentro de esta imagen
|
||||||
|
container:
|
||||||
|
image: golang:1.22-alpine
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
suffix: ""
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
suffix: ""
|
||||||
|
- goos: windows
|
||||||
|
goarch: amd64
|
||||||
|
suffix: ".exe"
|
||||||
|
- goos: darwin
|
||||||
|
goarch: amd64
|
||||||
|
suffix: ""
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm64
|
||||||
|
suffix: ""
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Compilar
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
run: |
|
||||||
|
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
|
||||||
|
mkdir -p dist
|
||||||
|
|
||||||
|
go build \
|
||||||
|
-ldflags="-w -s \
|
||||||
|
-X main.version=${{ gitea.ref_name }} \
|
||||||
|
-X main.commit=${{ gitea.sha }}" \
|
||||||
|
-o "dist/${BINARY_NAME}" \
|
||||||
|
./cmd/main.go
|
||||||
|
|
||||||
|
- name: Comprimir
|
||||||
|
run: |
|
||||||
|
cd dist
|
||||||
|
BINARY_NAME="app-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
|
||||||
|
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||||
|
apk add --no-cache zip
|
||||||
|
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
|
||||||
|
container:
|
||||||
|
image: alpine:3.19
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Instalar dependencias
|
||||||
|
run: apk add --no-cache git
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Descargar artefactos
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: dist/
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Generar changelog
|
||||||
|
run: |
|
||||||
|
PREV_TAG=$(git tag --sort=-version:refname | sed -n '2p')
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
git log --pretty=format:"- %s (%h)" | head -20 > changelog.txt
|
||||||
|
else
|
||||||
|
git log "${PREV_TAG}..${{ gitea.ref_name }}" \
|
||||||
|
--pretty=format:"- %s (%h)" > changelog.txt
|
||||||
|
fi
|
||||||
|
cat changelog.txt
|
||||||
|
|
||||||
|
- name: Crear checksums
|
||||||
|
run: |
|
||||||
|
cd dist
|
||||||
|
sha256sum * > checksums.txt
|
||||||
|
cat checksums.txt
|
||||||
|
|
||||||
|
- name: Crear Release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
tag_name: ${{ gitea.ref_name }}
|
||||||
|
name: "Release ${{ gitea.ref_name }}"
|
||||||
|
body_path: changelog.txt
|
||||||
|
files: |
|
||||||
|
dist/*.tar.gz
|
||||||
|
dist/checksums.txt
|
||||||
55
README.md
55
README.md
@@ -220,3 +220,58 @@ DOC_ID=$(./claudia-docs doc create -t "Report" -c "# Content" -p $PROJECT_ID --o
|
|||||||
./claudia-docs auth --help
|
./claudia-docs auth --help
|
||||||
./claudia-docs doc --help
|
./claudia-docs doc --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# En tu máquina local
|
||||||
|
git tag v1.0.0
|
||||||
|
git push origin v1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Secret necesario
|
||||||
|
|
||||||
|
En **Settings → Secrets → Actions** de tu repo:
|
||||||
|
|
||||||
|
| Secret | Cómo obtenerlo |
|
||||||
|
|---|---|
|
||||||
|
| `RELEASE_TOKEN` | Gitea → Settings → Applications → Generate Token (con permiso `write:repository`) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Estructura esperada del proyecto
|
||||||
|
```
|
||||||
|
mi-proyecto/
|
||||||
|
├── cmd/
|
||||||
|
│ └── main.go ← entrypoint
|
||||||
|
├── go.mod
|
||||||
|
├── go.sum
|
||||||
|
└── .gitea/
|
||||||
|
└── workflows/
|
||||||
|
└── release.yml
|
||||||
|
|
||||||
|
# Si main.go está en la raíz
|
||||||
|
-o "dist/${BINARY_NAME}" .
|
||||||
|
|
||||||
|
# Si está en otro lugar
|
||||||
|
-o "dist/${BINARY_NAME}" ./internal/cmd/server.go
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Resultado en Gitea
|
||||||
|
|
||||||
|
Una vez que hagas push del tag, en **Releases** del repo verás:
|
||||||
|
```
|
||||||
|
Release v1.0.0
|
||||||
|
├── app-linux-amd64.tar.gz
|
||||||
|
├── app-linux-arm64.tar.gz
|
||||||
|
├── app-darwin-amd64.tar.gz
|
||||||
|
├── app-darwin-arm64.tar.gz
|
||||||
|
├── app-windows-amd64.zip
|
||||||
|
└── checksums.txt
|
||||||
Reference in New Issue
Block a user