Skip to content

Commit 3f46be4

Browse files
author
scttymn
committed
build workflows
1 parent 708583b commit 3f46be4

File tree

4 files changed

+206
-2
lines changed

4 files changed

+206
-2
lines changed

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '1.21'
24+
25+
- name: Get the version
26+
id: get_version
27+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
28+
29+
- name: Build binaries
30+
run: |
31+
# Create dist directory
32+
mkdir -p dist
33+
34+
# Build for different platforms
35+
GOOS=linux GOARCH=amd64 go build -ldflags "-X gcpeasy/cmd.version=${{ steps.get_version.outputs.VERSION }}" -o dist/gcpeasy-linux-amd64 .
36+
GOOS=linux GOARCH=arm64 go build -ldflags "-X gcpeasy/cmd.version=${{ steps.get_version.outputs.VERSION }}" -o dist/gcpeasy-linux-arm64 .
37+
GOOS=darwin GOARCH=amd64 go build -ldflags "-X gcpeasy/cmd.version=${{ steps.get_version.outputs.VERSION }}" -o dist/gcpeasy-macos-amd64 .
38+
GOOS=darwin GOARCH=arm64 go build -ldflags "-X gcpeasy/cmd.version=${{ steps.get_version.outputs.VERSION }}" -o dist/gcpeasy-macos-arm64 .
39+
GOOS=windows GOARCH=amd64 go build -ldflags "-X gcpeasy/cmd.version=${{ steps.get_version.outputs.VERSION }}" -o dist/gcpeasy-windows-amd64.exe .
40+
41+
# Create compressed archives
42+
cd dist
43+
tar -czf gcpeasy-linux-amd64.tar.gz gcpeasy-linux-amd64
44+
tar -czf gcpeasy-linux-arm64.tar.gz gcpeasy-linux-arm64
45+
tar -czf gcpeasy-macos-amd64.tar.gz gcpeasy-macos-amd64
46+
tar -czf gcpeasy-macos-arm64.tar.gz gcpeasy-macos-arm64
47+
zip gcpeasy-windows-amd64.zip gcpeasy-windows-amd64.exe
48+
49+
- name: Generate changelog
50+
id: changelog
51+
run: |
52+
# Get commits since last tag
53+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
54+
if [ -n "$PREV_TAG" ]; then
55+
CHANGELOG=$(git log --pretty=format:"- %s" $PREV_TAG..HEAD)
56+
else
57+
CHANGELOG=$(git log --pretty=format:"- %s")
58+
fi
59+
60+
# Escape newlines for GitHub Actions
61+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
62+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
63+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
64+
65+
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_OUTPUT
66+
67+
- name: Create Release
68+
uses: actions/create-release@v1
69+
id: create_release
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
tag_name: ${{ steps.get_version.outputs.VERSION }}
74+
release_name: Release ${{ steps.get_version.outputs.VERSION }}
75+
body: |
76+
## Changes
77+
78+
${{ steps.changelog.outputs.CHANGELOG }}
79+
80+
## Installation
81+
82+
Download the appropriate binary for your platform:
83+
84+
### Linux
85+
```bash
86+
# AMD64
87+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/gcpeasy-linux-amd64.tar.gz | tar xz
88+
sudo mv gcpeasy-linux-amd64 /usr/local/bin/gcpeasy
89+
90+
# ARM64
91+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/gcpeasy-linux-arm64.tar.gz | tar xz
92+
sudo mv gcpeasy-linux-arm64 /usr/local/bin/gcpeasy
93+
```
94+
95+
### macOS
96+
```bash
97+
# Intel Macs
98+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/gcpeasy-macos-amd64.tar.gz | tar xz
99+
sudo mv gcpeasy-macos-amd64 /usr/local/bin/gcpeasy
100+
101+
# Apple Silicon Macs (M1/M2)
102+
curl -L https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.VERSION }}/gcpeasy-macos-arm64.tar.gz | tar xz
103+
sudo mv gcpeasy-macos-arm64 /usr/local/bin/gcpeasy
104+
```
105+
106+
### Windows
107+
Download `gcpeasy-windows-amd64.zip` and extract the executable.
108+
109+
## Verify Installation
110+
```bash
111+
gcpeasy --version
112+
```
113+
draft: false
114+
prerelease: false
115+
116+
- name: Upload Linux AMD64
117+
uses: actions/upload-release-asset@v1
118+
env:
119+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
with:
121+
upload_url: ${{ steps.create_release.outputs.upload_url }}
122+
asset_path: ./dist/gcpeasy-linux-amd64.tar.gz
123+
asset_name: gcpeasy-linux-amd64.tar.gz
124+
asset_content_type: application/gzip
125+
126+
- name: Upload Linux ARM64
127+
uses: actions/upload-release-asset@v1
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
with:
131+
upload_url: ${{ steps.create_release.outputs.upload_url }}
132+
asset_path: ./dist/gcpeasy-linux-arm64.tar.gz
133+
asset_name: gcpeasy-linux-arm64.tar.gz
134+
asset_content_type: application/gzip
135+
136+
- name: Upload macOS AMD64
137+
uses: actions/upload-release-asset@v1
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
with:
141+
upload_url: ${{ steps.create_release.outputs.upload_url }}
142+
asset_path: ./dist/gcpeasy-macos-amd64.tar.gz
143+
asset_name: gcpeasy-macos-amd64.tar.gz
144+
asset_content_type: application/gzip
145+
146+
- name: Upload macOS ARM64
147+
uses: actions/upload-release-asset@v1
148+
env:
149+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150+
with:
151+
upload_url: ${{ steps.create_release.outputs.upload_url }}
152+
asset_path: ./dist/gcpeasy-macos-arm64.tar.gz
153+
asset_name: gcpeasy-macos-arm64.tar.gz
154+
asset_content_type: application/gzip
155+
156+
- name: Upload Windows AMD64
157+
uses: actions/upload-release-asset@v1
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
with:
161+
upload_url: ${{ steps.create_release.outputs.upload_url }}
162+
asset_path: ./dist/gcpeasy-windows-amd64.zip
163+
asset_name: gcpeasy-windows-amd64.zip
164+
asset_content_type: application/zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gcpeasy

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,37 @@ A CLI tool to make GCP and Kubernetes workflows easy. gcpeasy streamlines workin
4545

4646
## Installation
4747

48+
### Download Pre-built Binaries (Recommended)
49+
50+
Download the latest release for your platform from the [releases page](https://github.com/your-username/gcpeasy/releases).
51+
52+
#### Linux
53+
```bash
54+
# AMD64
55+
curl -L https://github.com/your-username/gcpeasy/releases/latest/download/gcpeasy-linux-amd64.tar.gz | tar xz
56+
sudo mv gcpeasy-linux-amd64 /usr/local/bin/gcpeasy
57+
58+
# ARM64
59+
curl -L https://github.com/your-username/gcpeasy/releases/latest/download/gcpeasy-linux-arm64.tar.gz | tar xz
60+
sudo mv gcpeasy-linux-arm64 /usr/local/bin/gcpeasy
61+
```
62+
63+
#### macOS
64+
```bash
65+
# Intel Macs
66+
curl -L https://github.com/your-username/gcpeasy/releases/latest/download/gcpeasy-macos-amd64.tar.gz | tar xz
67+
sudo mv gcpeasy-macos-amd64 /usr/local/bin/gcpeasy
68+
69+
# Apple Silicon Macs (M1/M2)
70+
curl -L https://github.com/your-username/gcpeasy/releases/latest/download/gcpeasy-macos-arm64.tar.gz | tar xz
71+
sudo mv gcpeasy-macos-arm64 /usr/local/bin/gcpeasy
72+
```
73+
74+
#### Windows
75+
Download `gcpeasy-windows-amd64.zip` from the releases page and extract the executable.
76+
77+
### Build from Source
78+
4879
```bash
4980
# Clone the repository
5081
git clone <repository-url>
@@ -57,6 +88,11 @@ go build -o gcpeasy
5788
mv gcpeasy /usr/local/bin/
5889
```
5990

91+
### Verify Installation
92+
```bash
93+
gcpeasy --version
94+
```
95+
6096
## Quick Start
6197

6298
1. **Authenticate with Google Cloud:**

cmd/root.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9+
var version = "dev" // Will be set by build flags
10+
911
var rootCmd = &cobra.Command{
10-
Use: "gcpeasy",
11-
Short: "A CLI tool to make GCP and Kubernetes workflows easy",
12+
Use: "gcpeasy",
13+
Version: version,
14+
Short: "A CLI tool to make GCP and Kubernetes workflows easy",
1215
Long: `gcpeasy streamlines working with Google Cloud Platform and Kubernetes infrastructure
1316
by providing simple commands for common development workflows. It eliminates the need
1417
to remember complex kubectl and gcloud commands and automates environment switching.`,

0 commit comments

Comments
 (0)