Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
124 changes: 124 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Auto Release

on:
push:
branches:
- main # Trigger when code is merged to main

permissions:
contents: write # Required for pushing tags and creating releases

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch tags

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Determine next version
id: version
run: |
# Get latest tag (default to v0.0.0 if none)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")

echo "Last tag: $LAST_TAG"

# Extract major, minor, patch using regex
VERSION_PARTS=(${LAST_TAG//./ })
MAJOR=$(echo ${VERSION_PARTS[0]} | sed 's/v//')
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}

# Bump patch version (change this logic for major/minor)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v$MAJOR.$MINOR.$NEW_PATCH"

echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version will be: $NEW_VERSION"

- name: Create and push tag
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag ${{ steps.version.outputs.NEW_VERSION }}
git push origin ${{ steps.version.outputs.NEW_VERSION }}

- name: Build binaries
run: |
mkdir -p dist
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-linux-amd64
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/uve-darwin-arm64
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-windows-amd64.exe

- name: Package release assets
run: |
cd dist
tar czf uve-linux-amd64.tar.gz uve-linux-amd64
tar czf uve-darwin-amd64.tar.gz uve-darwin-amd64
tar czf uve-darwin-arm64.tar.gz uve-darwin-arm64
zip uve-windows-amd64.zip uve-windows-amd64.exe
rm uve-* # Clean up raw binaries

- name: Create install script
run: |
cat << 'EOF' > dist/uve-install.sh
#!/bin/bash
# UVE Installer
set -euo pipefail

BASE_URL="https://github.com/iamshreeram/uve/releases/latest/download"
TEMP_DIR=$(mktemp -d)

# Detect OS and Architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

case $ARCH in
x86_64) ARCH="amd64" ;;
arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture"; exit 1 ;;
esac

# Download appropriate binary
echo "Downloading UVE for ${OS}-${ARCH}..."
case $OS in
linux|darwin)
curl -L "${BASE_URL}/uve-${OS}-${ARCH}.tar.gz" -o "${TEMP_DIR}/uve.tar.gz"
tar -xzf "${TEMP_DIR}/uve.tar.gz" -C "${TEMP_DIR}"
BIN_PATH="${HOME}/.local/bin"
mkdir -p "${BIN_PATH}"
mv "${TEMP_DIR}/uve-bin" "${BIN_PATH}/uve"
chmod +x "${BIN_PATH}/uve"
;;
*)
echo "Unsupported OS"; exit 1 ;;
esac

# Initialize shell
echo "Setting up shell integration..."
"${BIN_PATH}/uve" init

echo "UVE installed successfully to ${BIN_PATH}"
echo "Please restart your shell or run: source ~/.bashrc (or equivalent)"

EOF
chmod +x dist/uve-install.sh

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.NEW_VERSION }}
files: |
dist/*.tar.gz
dist/*.zip
dist/uve-install.sh
generate_release_notes: true
Loading
Loading