ci: automatic version + releases tag
Some checks failed
bump-version / bump (push) Has been cancelled

This commit is contained in:
Victor Hugo Vargas Servin 2026-08-02 18:25:14 -07:00
parent cde9ac3544
commit 6e9211b5a0
7 changed files with 378 additions and 1 deletions

View file

@ -0,0 +1,69 @@
name: bump-version
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: bump-version
cancel-in-progress: false
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.FORGEJO_TOKEN }}
- name: Skip if latest commit is already a release commit
run: |
SUBJECT=$(git log -1 --pretty=%s)
if [[ "$SUBJECT" == chore(release):* ]]; then
echo "Latest commit is a release commit ('$SUBJECT'). Skipping bump to avoid loop."
exit 0
fi
echo "Latest commit subject: $SUBJECT — proceeding with bump."
- name: Read current version
id: current
run: |
if [[ ! -f VERSION ]]; then
echo "VERSION file missing"
exit 1
fi
VERSION=$(tr -d '[:space:]' < VERSION)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Compute next patch version
id: next
run: |
CURRENT="${{ steps.current.outputs.version }}"
STRIP_LEADING_V='s/^v//'
CORE=$(echo "$CURRENT" | sed -E "$STRIP_LEADING_V")
BASE="${CORE%%-*}"
SUFFIX=""
if [[ "$CORE" == *-* ]]; then
SUFFIX="-${CORE#*-}"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then
echo "Cannot parse version: $CURRENT"
exit 1
fi
NEXT="v${MAJOR}.${MINOR}.$((PATCH + 1))${SUFFIX}"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "Bumping $CURRENT → $NEXT"
- name: Update VERSION and push bump commit
run: |
NEXT="${{ steps.next.outputs.next }}"
printf '%s\n' "$NEXT" > VERSION
git config user.name "forgejo-actions[bot]"
git config user.email "forgejo-actions[bot]@noreply.${FORGEJO_DOMAIN:-src.sersofts.org}"
git add VERSION
git commit -m "chore(release): bump version to $NEXT"
git push origin HEAD:main

View file

@ -0,0 +1,100 @@
name: release
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-*'
jobs:
build:
name: Build (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
ext: ''
- os: linux
arch: arm64
ext: ''
- os: darwin
arch: amd64
ext: ''
- os: darwin
arch: arm64
ext: ''
- os: windows
arch: amd64
ext: '.exe'
- os: windows
arch: arm64
ext: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.FORGEJO_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
- name: Build binary
env:
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
mkdir -p dist
OUT="dist/rony-llm-agent-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} \
go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION}" \
-o "$OUT" \
./cmd/rony-llm-agent
echo "Built $OUT"
ls -lh "$OUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rony-llm-agent-${{ matrix.os }}-${{ matrix.arch }}
path: dist/rony-llm-agent-*
if-no-files-found: error
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifacts
run: |
mkdir -p release
find dist -type f -name 'rony-llm-agent-*' -exec mv {} release/ \;
ls -lh release/
- name: Generate checksums
run: |
cd release
sha256sum * > SHA256SUMS
ls -lh
- name: Create Forgejo release
uses: https://code.forgejo.org/actions/forgejo-release@v2
with:
url: ${{ github.server_url }}
token: ${{ secrets.FORGEJO_TOKEN }}
tag: ${{ github.ref_name }}
release-dir: release
prerelease: ${{ contains(github.ref_name, '-') }}
release-notes: "Release ${{ github.ref_name }}"

72
.github/workflows/bump-version.yml vendored Normal file
View file

@ -0,0 +1,72 @@
name: bump-version
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: bump-version
cancel-in-progress: false
permissions:
contents: write
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Skip if latest commit is already a release commit
run: |
SUBJECT=$(git log -1 --pretty=%s)
if [[ "$SUBJECT" == chore(release):* ]]; then
echo "Latest commit is a release commit ('$SUBJECT'). Skipping bump to avoid loop."
exit 0
fi
echo "Latest commit subject: $SUBJECT — proceeding with bump."
- name: Read current version
id: current
run: |
if [[ ! -f VERSION ]]; then
echo "VERSION file missing"
exit 1
fi
VERSION=$(tr -d '[:space:]' < VERSION)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Compute next patch version
id: next
run: |
CURRENT="${{ steps.current.outputs.version }}"
STRIP_LEADING_V='s/^v//'
CORE=$(echo "$CURRENT" | sed -E "$STRIP_LEADING_V")
BASE="${CORE%%-*}"
SUFFIX=""
if [[ "$CORE" == *-* ]]; then
SUFFIX="-${CORE#*-}"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE"
if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then
echo "Cannot parse version: $CURRENT"
exit 1
fi
NEXT="v${MAJOR}.${MINOR}.$((PATCH + 1))${SUFFIX}"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
echo "Bumping $CURRENT → $NEXT"
- name: Update VERSION and push bump commit
run: |
NEXT="${{ steps.next.outputs.next }}"
printf '%s\n' "$NEXT" > VERSION
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION
git commit -m "chore(release): bump version to $NEXT"
git push origin HEAD:main

103
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,103 @@
name: release
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-*'
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
ext: ''
- os: linux
arch: arm64
ext: ''
- os: darwin
arch: amd64
ext: ''
- os: darwin
arch: arm64
ext: ''
- os: windows
arch: amd64
ext: '.exe'
- os: windows
arch: arm64
ext: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
- name: Build binary
env:
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
mkdir -p dist
OUT="dist/rony-llm-agent-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}"
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} \
go build -trimpath \
-ldflags "-s -w -X main.version=${VERSION}" \
-o "$OUT" \
./cmd/rony-llm-agent
echo "Built $OUT"
ls -lh "$OUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rony-llm-agent-${{ matrix.os }}-${{ matrix.arch }}
path: dist/rony-llm-agent-*
if-no-files-found: error
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Flatten artifacts
run: |
mkdir -p release
find dist -type f -name 'rony-llm-agent-*' -exec mv {} release/ \;
ls -lh release/
- name: Generate checksums
run: |
cd release
sha256sum * > SHA256SUMS
ls -lh
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
name: ${{ github.ref_name }}
prerelease: ${{ contains(github.ref_name, '-') }}
generate_release_notes: true
files: |
release/*

1
.gitignore vendored
View file

@ -17,3 +17,4 @@ coverage.html
# Local build cache # Local build cache
.cache/ .cache/
dist/

1
VERSION Normal file
View file

@ -0,0 +1 @@
v0.1.0-alpha

View file

@ -0,0 +1,31 @@
package main
import (
"fmt"
"os"
)
var version = "dev"
const usage = `rony-llm-agent minimal CLI for the rony-llm-agent library
Usage:
rony-llm-agent version Print the library version and exit
rony-llm-agent help Print this help message and exit`
func main() {
if len(os.Args) < 2 {
fmt.Fprintln(os.Stderr, usage)
os.Exit(1)
}
switch os.Args[1] {
case "version", "--version", "-v":
fmt.Printf("rony-llm-agent %s\n", version)
case "help", "--help", "-h":
fmt.Println(usage)
default:
fmt.Fprintf(os.Stderr, "unknown command: %s\n\n%s", os.Args[1], usage)
os.Exit(1)
}
}