-
Notifications
You must be signed in to change notification settings - Fork 1
138 lines (114 loc) · 4.93 KB
/
Copy pathrelease.yml
File metadata and controls
138 lines (114 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build & Release
on:
push:
branches: [main]
permissions:
contents: write # needed to create tags and GitHub releases
jobs:
release:
name: Build and publish release
runs-on: ubuntu-latest
steps:
# ── 1. Checkout with full tag history ───────────────────────────
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # required to see all existing tags
# ── 2. Compute the next minor version ───────────────────────────
- name: Compute next version
id: version
run: |
git fetch --tags --force
# Find the latest semver tag (vMAJOR.MINOR.PATCH)
LATEST=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
if [ -z "$LATEST" ]; then
# No tags yet — start at v0.1.0
NEW_TAG="v0.1.0"
else
MAJOR=$(echo "$LATEST" | cut -d. -f1 | tr -d 'v')
MINOR=$(echo "$LATEST" | cut -d. -f2)
NEW_MINOR=$((MINOR + 1))
NEW_TAG="v${MAJOR}.${NEW_MINOR}.0"
fi
echo "previous=${LATEST:-none}"
echo "tag=$NEW_TAG"
echo "tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
# ── 3. Set up Go ────────────────────────────────────────────────
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod # honours the 'go' directive in go.mod
cache: true
# ── 4. Build for all platforms ──────────────────────────────────
- name: Build binaries
env:
VERSION: ${{ steps.version.outputs.tag }}
LDFLAGS: -s -w -X main.version=${{ steps.version.outputs.tag }}
run: |
mkdir -p dist
echo "Building $VERSION …"
GOOS=windows GOARCH=amd64 go build -ldflags="$LDFLAGS" \
-o dist/androidbackup-windows-amd64.exe .
GOOS=linux GOARCH=amd64 go build -ldflags="$LDFLAGS" \
-o dist/androidbackup-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -ldflags="$LDFLAGS" \
-o dist/androidbackup-linux-arm64 .
GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" \
-o dist/androidbackup-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" \
-o dist/androidbackup-darwin-arm64 .
echo "Built artifacts:"
ls -lh dist/
# ── 5. Collect commit messages for the release body ─────────────
- name: Build changelog
id: changelog
run: |
PREV=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
if [ -z "$PREV" ]; then
LOG=$(git log --oneline | head -20)
else
LOG=$(git log "${PREV}..HEAD" --oneline)
fi
# Escape for multiline GitHub output
echo "log<<EOF" >> "$GITHUB_OUTPUT"
echo "$LOG" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
# ── 6. Create GitHub release with binaries ──────────────────────
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: |
## Changes
```
${{ steps.changelog.outputs.log }}
```
## Downloads
| Platform | Architecture | Binary |
|----------|--------------|--------|
| Windows | x64 | `androidbackup-windows-amd64.exe` |
| Linux | x64 | `androidbackup-linux-amd64` |
| Linux | ARM64 | `androidbackup-linux-arm64` |
| macOS | x64 | `androidbackup-darwin-amd64` |
| macOS | Apple Silicon| `androidbackup-darwin-arm64` |
## Requirements
- [ADB (Android Debug Bridge)](https://developer.android.com/tools/releases/platform-tools) must be installed and in your `PATH`
## Usage
```
# Windows
.\androidbackup-windows-amd64.exe
# Linux / macOS (make executable first)
chmod +x androidbackup-linux-amd64
./androidbackup-linux-amd64
```
Opens at **http://localhost:8765**
files: |
dist/androidbackup-windows-amd64.exe
dist/androidbackup-linux-amd64
dist/androidbackup-linux-arm64
dist/androidbackup-darwin-amd64
dist/androidbackup-darwin-arm64
draft: false
prerelease: false
make_latest: true