diff --git a/.forgejo/workflows/bump-version.yml b/.forgejo/workflows/bump-version.yml new file mode 100644 index 0000000..0bd7439 --- /dev/null +++ b/.forgejo/workflows/bump-version.yml @@ -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 diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..ee7de9c --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -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 }}" diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000..0543900 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fa06a32 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/* diff --git a/.gitignore b/.gitignore index 4965a9b..f835cea 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ coverage.html .DS_Store # Local build cache -.cache/ \ No newline at end of file +.cache/ +dist/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..48f1962 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.1.0-alpha diff --git a/cmd/rony-llm-agent/main.go b/cmd/rony-llm-agent/main.go new file mode 100644 index 0000000..637379b --- /dev/null +++ b/cmd/rony-llm-agent/main.go @@ -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) + } +}