Skip to content

Commit 93ffdb0

Browse files
committed
[dev] Release action
Tool: gitpod/catfood.gitpod.cloud
1 parent b347350 commit 93ffdb0

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: '1.23.1'
19+
check-latest: true
20+
21+
- name: Build binaries
22+
run: |
23+
# Build for multiple platforms
24+
GOOS=linux GOARCH=amd64 go build -o prometheus-decoder-linux-amd64
25+
GOOS=darwin GOARCH=amd64 go build -o prometheus-decoder-darwin-amd64
26+
GOOS=darwin GOARCH=arm64 go build -o prometheus-decoder-darwin-arm64
27+
GOOS=windows GOARCH=amd64 go build -o prometheus-decoder-windows-amd64.exe
28+
29+
- name: Create Release
30+
uses: softprops/action-gh-release@v1
31+
with:
32+
files: |
33+
prometheus-decoder-linux-amd64
34+
prometheus-decoder-darwin-amd64
35+
prometheus-decoder-darwin-arm64
36+
prometheus-decoder-windows-amd64.exe
37+
generate_release_notes: true

.gitignore

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

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,39 @@ Usage of ./prometheus-decoder:
1616
Output file for JSON results (default: stdout)
1717
-pretty
1818
Enable pretty-printing of JSON output (default true)
19-
```
19+
-version
20+
Show version information and exit
21+
```
22+
23+
## Installation
24+
25+
### Download from GitHub Releases
26+
27+
You can download the latest pre-built binary for your platform from the [GitHub Releases page](https://github.com/gitpod-io/prometheus-decoder/releases).
28+
29+
### Build from Source
30+
31+
```bash
32+
git clone https://github.com/gitpod-io/prometheus-decoder.git
33+
cd prometheus-decoder
34+
go build
35+
```
36+
37+
## Development
38+
39+
This project uses GitHub Actions to automatically build and publish releases when a new tag is pushed to the repository.
40+
41+
### Creating a New Release
42+
43+
1. Update the version number in `main.go`
44+
2. Commit your changes
45+
3. Tag the commit with a version number:
46+
```bash
47+
git tag v0.1.0
48+
git push origin v0.1.0
49+
```
50+
4. GitHub Actions will automatically build binaries for multiple platforms and create a new release
51+
52+
### Version History
53+
54+
- v0.1.0 - Initial release

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import (
1313
"github.com/prometheus/prometheus/prompb"
1414
)
1515

16+
// Version information
17+
const (
18+
Version = "0.1.0"
19+
)
20+
1621
// PrometheusRecord is the ndjson-encoded format used for transporting metrics through firehose
1722
type PrometheusRecord struct {
1823
Body []byte `json:"b"`
@@ -114,8 +119,15 @@ func main() {
114119
outputFile := flag.String("output", "", "Output file for JSON results (default: stdout)")
115120
prettyPrint := flag.Bool("pretty", true, "Enable pretty-printing of JSON output")
116121
humanTime := flag.Bool("human-time", false, "Show human-readable timestamps in output")
122+
showVersion := flag.Bool("version", false, "Show version information and exit")
117123
flag.Parse()
118124

125+
// Show version if requested
126+
if *showVersion {
127+
fmt.Printf("prometheus-decoder version %s\n", Version)
128+
os.Exit(0)
129+
}
130+
119131
if *inputFile == "" {
120132
fmt.Println("Error: Input file is required")
121133
flag.Usage()

0 commit comments

Comments
 (0)