Skip to content

Commit

Permalink
A new start
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed May 31, 2024
0 parents commit a418423
Show file tree
Hide file tree
Showing 19 changed files with 1,671 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build and release
on:
workflow_dispatch:
push:
branches:
- main
- dev
paths:
- 'main.go'
- 'go.mod'
- '.github/workflows/build-and-release.yml'
tags:
- v*
pull_request:
branches:
- main

permissions:
contents: write
checks: write
pull-requests: write
packages: write

concurrency:
group: build-and-release
cancel-in-progress: true

jobs:
build-and-release:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5
with:
go-version: 1.22.1

# Install dependencies
- name: Install dependencies
run: go mod download

# Build
- name: Build macOS ARM64
run: |
GOOS=darwin GOARCH=arm64 go build -o main.go -o gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
echo "macOS ARM64 build completed" >> "$GITHUB_STEP_SUMMARY"
- name: Build Linux
run: |
GOOS=linux GOARCH=amd64 go build -o main.go -o gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }}
GOOS=linux GOARCH=arm64 go build -o main.go -o gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
echo "Linux build completed" >> "$GITHUB_STEP_SUMMARY"
- name: Upload artefacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: gollama
path: |
gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }}
gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
# Bump version
- name: Bump version and push tag
id: tag_version
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]')
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main
pre_release_branches: dev

# Publish
- name: Create a GitHub release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main') && !contains(github.event.head_commit.message, '[skip ci]')
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true
allowUpdates: true
prerelease: ${{ startsWith(github.ref, 'refs/heads/dev') }}
artifacts: |
gollama-macos-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
gollama-linux-amd64${{ github.ref == 'refs/heads/dev' && '-dev' }}
gollama-linux-arm64${{ github.ref == 'refs/heads/dev' && '-dev' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gollama
**/.swp
**/.tmp
**/.trash
**/*.log
dist/
.selected*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sam McLeod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#### Dynamically Generated Interactive Menu ####

# Error Handling
SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -c

# Name of this Makefile
MAKEFILE_NAME := $(lastword $(MAKEFILE_LIST))

# Special targets that should not be listed
EXCLUDE_LIST := menu all .PHONY

# Function to extract targets from the Makefile
define extract_targets
$(shell awk -F: '/^[a-zA-Z0-9_-]+:/ {print $$1}' $(MAKEFILE_NAME) | grep -v -E '^($(EXCLUDE_LIST))$$')
endef

TARGETS := $(call extract_targets)

.PHONY: $(TARGETS) menu all

menu: ## Makefile Interactive Menu
@# Check if fzf is installed
@if command -v fzf >/dev/null 2>&1; then \
echo "Using fzf for selection..."; \
echo "$(TARGETS)" | tr ' ' '\n' | fzf > .selected_target; \
target_choice=$$(cat .selected_target); \
else \
echo "fzf not found, using numbered menu:"; \
echo "$(TARGETS)" | tr ' ' '\n' > .targets; \
awk '{print NR " - " $$0}' .targets; \
read -p "Enter choice: " choice; \
target_choice=$$(awk 'NR == '$$choice' {print}' .targets); \
fi; \
if [ -n "$$target_choice" ]; then \
$(MAKE) $$target_choice; \
else \
echo "Invalid choice"; \
fi

# Default target
all: menu

help: ## This help function
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

# Targets (example targets listed below)
lint: ## Run lint
gofmt -w .

test: ## Run test
go test -v ./...

build: ## Run build
go build .

run: ## Run
go run *.go
Loading

0 comments on commit a418423

Please sign in to comment.