Skip to content

Commit 4fd9c70

Browse files
authored
Merge pull request #56 from maniac-en/maniac/hotfixes-and-good-to-haves
feat: Fix GitHub Actions workflows and add release process
2 parents 66ea0a7 + 807a447 commit 4fd9c70

12 files changed

+377
-29
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
format:
4747
name: Auto-format with gofmt (Linux only)
4848
runs-on: ubuntu-latest
49-
if: github.event_name == 'push'
49+
if: github.event_name == 'push' && github.actor != 'github-actions[bot]'
5050
permissions:
5151
contents: write
5252

.github/workflows/pages.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'docs/**'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
deploy:
22+
environment:
23+
name: github-pages
24+
url: ${{ steps.deployment.outputs.page_url }}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Pages
31+
uses: actions/configure-pages@v4
32+
33+
- name: Upload artifact
34+
uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: './docs'
37+
38+
- name: Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,103 @@
1-
name: Release on merge of versioned branch into main
1+
name: Release on Git Tag
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
branches:
7-
- main
4+
push:
5+
tags:
6+
- 'v*'
87

98
jobs:
109
release:
11-
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'v')
1210
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
strategy:
14+
matrix:
15+
goos: [linux, darwin, windows]
16+
goarch: [amd64, arm64]
17+
exclude:
18+
- goos: windows
19+
goarch: arm64
1320

1421
steps:
1522
- name: Checkout code
1623
uses: actions/checkout@v4
1724

18-
- name: Extract version from branch name
19-
run: echo "VERSION=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
25+
- name: Extract version from tag
26+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2027

2128
- name: Set up Go
2229
uses: actions/setup-go@v5
2330
with:
2431
go-version: '1.24.4'
2532

26-
- name: Build with version
27-
run: go build -ldflags "-X main.Version=${VERSION}" -o req
28-
29-
- name: Tag main with version
33+
- name: Build binary for ${{ matrix.goos }}-${{ matrix.goarch }}
34+
env:
35+
GOOS: ${{ matrix.goos }}
36+
GOARCH: ${{ matrix.goarch }}
3037
run: |
31-
git config user.name "github-actions"
32-
git config user.email "github-actions@github.com"
33-
git fetch --unshallow --tags
34-
git tag "${VERSION}"
35-
git push origin "${VERSION}"
38+
BINARY_NAME="req-${{ env.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}"
39+
if [ "${{ matrix.goos }}" = "windows" ]; then
40+
BINARY_NAME="${BINARY_NAME}.exe"
41+
fi
42+
go build -ldflags "-X main.Version=${{ env.VERSION }}" -o "${BINARY_NAME}" .
43+
echo "BINARY_NAME=${BINARY_NAME}" >> $GITHUB_ENV
44+
45+
- name: Upload binary as artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: ${{ env.BINARY_NAME }}
49+
path: ${{ env.BINARY_NAME }}
50+
51+
create-release:
52+
needs: release
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: write
56+
57+
steps:
58+
- name: Extract version from tag
59+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
60+
61+
- name: Download all artifacts
62+
uses: actions/download-artifact@v4
63+
with:
64+
path: ./binaries
3665

3766
- name: Create GitHub Release
3867
uses: softprops/action-gh-release@v2
3968
with:
4069
tag_name: ${{ env.VERSION }}
41-
files: req
70+
name: "Req ${{ env.VERSION }}"
71+
body: |
72+
A terminal-based API client built for the Boot.dev Hackathon 2025.
73+
74+
**Installation:**
75+
```bash
76+
go install github.com/maniac-en/req@${{ env.VERSION }}
77+
```
78+
79+
**Prebuilt binaries:**
80+
- Linux: `req-${{ env.VERSION }}-linux-amd64`, `req-${{ env.VERSION }}-linux-arm64`
81+
- macOS: `req-${{ env.VERSION }}-darwin-amd64`, `req-${{ env.VERSION }}-darwin-arm64`
82+
- Windows: `req-${{ env.VERSION }}-windows-amd64.exe`
83+
84+
**Usage:** Run `req` in your terminal
85+
86+
**Breaking Changes:**
87+
Database schema has been updated. Please remove your existing database:
88+
```bash
89+
# Linux/macOS
90+
rm ~/.cache/req/app.db
91+
92+
# Windows
93+
del %LOCALAPPDATA%\req\app.db
94+
```
95+
96+
**Note:** This is early development software. Core HTTP execution features are still in progress.
97+
98+
Full changelog: https://github.com/maniac-en/req/commits/${{ env.VERSION }}
99+
files: ./binaries/**/*
100+
draft: false
101+
prerelease: ${{ contains(env.VERSION, '-') }}
42102
env:
43103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CONTRIBUTING.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributing to Req
2+
3+
## Release Process
4+
5+
To create a new release:
6+
7+
1. Ensure changes are merged to `main`
8+
2. Create and push a Git tag:
9+
```bash
10+
git tag v0.1.0-alpha.2
11+
git push origin v0.1.0-alpha.2
12+
```
13+
3. GitHub Actions automatically builds and creates the release
14+
15+
For detailed release information, see [RELEASE.md](RELEASE.md).
16+
17+
## GitHub Actions Workflows
18+
19+
### CI/CD Pipeline (`.github/workflows/ci-cd.yml`)
20+
Triggers: Push to `main`, Pull requests to `main`
21+
22+
Jobs:
23+
- build-test: Cross-platform testing (Ubuntu/macOS/Windows)
24+
- Builds project and runs tests with coverage
25+
- format: Auto-formats Go code with `gofmt`
26+
- Commits formatting changes automatically
27+
- Skips if author is `github-actions[bot]` to prevent cascading
28+
29+
### Release Pipeline (`.github/workflows/release.yml`)
30+
Triggers: Git tag push matching `v*` pattern
31+
32+
Jobs:
33+
- release: Builds binaries for Linux/macOS/Windows (amd64/arm64)
34+
- create-release: Creates GitHub release with binaries and release notes
35+
36+
## Development Workflow
37+
38+
### Building and Testing
39+
```bash
40+
# Build for development
41+
go build -o ./tmp/req .
42+
43+
# Run tests with coverage
44+
go test -coverprofile=coverage.out ./...
45+
go tool cover -func=coverage.out
46+
47+
# Format code (or let CI handle it)
48+
go fmt ./...
49+
```
50+
51+
### Database Changes
52+
```bash
53+
# Create new migration
54+
goose -dir db/migrations create migration_name sql
55+
56+
# Generate SQLC code after modifying queries
57+
sqlc generate
58+
```
59+
60+
### Installation Methods
61+
After release, users can install via:
62+
```bash
63+
# Latest stable release
64+
go install github.com/maniac-en/req@latest
65+
66+
# Specific version
67+
go install github.com/maniac-en/req@v0.1.0-alpha.2
68+
```
69+
70+
## Branch Strategy
71+
- main: Primary development branch
72+
- Feature branches: Create for new work, merge via PRs
73+
- Releases: Use Git tags, not version branches
74+
75+
## Troubleshooting
76+
- CI formatting failures: Auto-fixed by format job
77+
- Release not triggering: Ensure Git tag starts with `v`
78+
- GitHub Pages builds: Expected to be cancelled (we use Git tags for distribution)

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Req - Test APIs with Terminal Velocity
22

3-
[![tests](https://github.com/maniac-en/req/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/maniac-en/req/actions/workflows/go.yml)
3+
[![tests](https://github.com/maniac-en/req/actions/workflows/ci-cd.yml/badge.svg?branch=main)](https://github.com/maniac-en/req/actions/workflows/ci-cd.yml)
44
![GitHub repo](https://img.shields.io/badge/built%20at-Boot.dev%20Hackathon-blueviolet)
55

66
## About
@@ -16,15 +16,15 @@ Read more about `req` over here -
1616

1717
## Installation
1818

19-
### You can install `req` using `go install`:
19+
Install `req` using `go install`:
2020

21-
To install a specific release
22-
23-
```
21+
```bash
22+
# Install the latest stable release
2423
go install github.com/maniac-en/req@latest
25-
```
2624

27-
Replace `latest` with the specific version you want.
25+
# Or install a specific version (e.g., v0.1.0)
26+
go install github.com/maniac-en/req@v0.1.0
27+
```
2828

2929
### Requirements
3030

0 commit comments

Comments
 (0)