Skip to content

Commit bab5823

Browse files
Merge pull request #9 from iamshreeram/main
Fixing release pipeline
2 parents 8c3be15 + 0886e58 commit bab5823

File tree

6 files changed

+442
-308
lines changed

6 files changed

+442
-308
lines changed

.github/workflows/go.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow will build a golang project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
3+
4+
name: Go
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.20'
23+
24+
- name: Build
25+
run: go build -v ./...
26+
27+
- name: Test
28+
run: go test -v ./...

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Auto Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger when code is merged to main
7+
8+
permissions:
9+
contents: write # Required for pushing tags and creating releases
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Required to fetch tags
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v4
23+
with:
24+
go-version: '1.21'
25+
26+
- name: Determine next version
27+
id: version
28+
run: |
29+
# Get latest tag (default to v0.0.0 if none)
30+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
31+
32+
echo "Last tag: $LAST_TAG"
33+
34+
# Extract major, minor, patch using regex
35+
VERSION_PARTS=(${LAST_TAG//./ })
36+
MAJOR=$(echo ${VERSION_PARTS[0]} | sed 's/v//')
37+
MINOR=${VERSION_PARTS[1]}
38+
PATCH=${VERSION_PARTS[2]}
39+
40+
# Bump patch version (change this logic for major/minor)
41+
NEW_PATCH=$((PATCH + 1))
42+
NEW_VERSION="v$MAJOR.$MINOR.$NEW_PATCH"
43+
44+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
45+
echo "New version will be: $NEW_VERSION"
46+
47+
- name: Create and push tag
48+
run: |
49+
git config user.name "github-actions"
50+
git config user.email "[email protected]"
51+
git tag ${{ steps.version.outputs.NEW_VERSION }}
52+
git push origin ${{ steps.version.outputs.NEW_VERSION }}
53+
54+
- name: Build binaries
55+
run: |
56+
mkdir -p dist
57+
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-linux-amd64
58+
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-darwin-amd64
59+
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/uve-darwin-arm64
60+
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/uve-windows-amd64.exe
61+
62+
- name: Package release assets
63+
run: |
64+
cd dist
65+
tar czf uve-linux-amd64.tar.gz uve-linux-amd64
66+
tar czf uve-darwin-amd64.tar.gz uve-darwin-amd64
67+
tar czf uve-darwin-arm64.tar.gz uve-darwin-arm64
68+
zip uve-windows-amd64.zip uve-windows-amd64.exe
69+
rm uve-* # Clean up raw binaries
70+
71+
- name: Create install script
72+
run: |
73+
cat << 'EOF' > dist/uve-install.sh
74+
#!/bin/bash
75+
# UVE Installer
76+
set -euo pipefail
77+
78+
BASE_URL="https://github.com/iamshreeram/uve/releases/latest/download"
79+
TEMP_DIR=$(mktemp -d)
80+
81+
# Detect OS and Architecture
82+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
83+
ARCH=$(uname -m)
84+
85+
case $ARCH in
86+
x86_64) ARCH="amd64" ;;
87+
arm64) ARCH="arm64" ;;
88+
*) echo "Unsupported architecture"; exit 1 ;;
89+
esac
90+
91+
# Download appropriate binary
92+
echo "Downloading UVE for ${OS}-${ARCH}..."
93+
case $OS in
94+
linux|darwin)
95+
curl -L "${BASE_URL}/uve-${OS}-${ARCH}.tar.gz" -o "${TEMP_DIR}/uve.tar.gz"
96+
tar -xzf "${TEMP_DIR}/uve.tar.gz" -C "${TEMP_DIR}"
97+
BIN_PATH="${HOME}/.local/bin"
98+
mkdir -p "${BIN_PATH}"
99+
mv "${TEMP_DIR}/uve-bin" "${BIN_PATH}/uve"
100+
chmod +x "${BIN_PATH}/uve"
101+
;;
102+
*)
103+
echo "Unsupported OS"; exit 1 ;;
104+
esac
105+
106+
# Initialize shell
107+
echo "Setting up shell integration..."
108+
"${BIN_PATH}/uve" init
109+
110+
echo "UVE installed successfully to ${BIN_PATH}"
111+
echo "Please restart your shell or run: source ~/.bashrc (or equivalent)"
112+
113+
EOF
114+
chmod +x dist/uve-install.sh
115+
116+
- name: Create GitHub Release
117+
uses: softprops/action-gh-release@v1
118+
with:
119+
tag_name: ${{ steps.version.outputs.NEW_VERSION }}
120+
files: |
121+
dist/*.tar.gz
122+
dist/*.zip
123+
dist/uve-install.sh
124+
generate_release_notes: true

0 commit comments

Comments
 (0)