-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (135 loc) · 4.76 KB
/
release.yml
File metadata and controls
154 lines (135 loc) · 4.76 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Auto-tag and publish cross-compiled agentctl binaries on each merge to main (patch bump),
# or manually with workflow_dispatch (patch / minor / major).
name: Release
on:
push:
branches:
- main
paths-ignore:
- "Makefile"
- "**/*.md"
workflow_dispatch:
inputs:
bump:
description: "Semver bump over the latest v*.*.* tag"
type: choice
options:
- patch
- minor
- major
default: patch
permissions:
contents: write
concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false
jobs:
release:
name: Tag, build, and publish binaries
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute next version tag
id: version
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_BUMP: ${{ github.event.inputs.bump }}
run: |
set -euo pipefail
BUMP=patch
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
BUMP="${INPUT_BUMP:-patch}"
fi
git fetch --tags --force
latest=""
while IFS= read -r t; do
if [[ "$t" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
latest="$t"
break
fi
done < <(git tag -l 'v*' --sort=-v:refname)
if [ -z "$latest" ]; then
case "$BUMP" in
major) next="v1.0.0" ;;
*) next="v0.1.0" ;;
esac
echo "Latest stable tag: <none>"
echo "First release ($BUMP) → $next"
echo "tag=$next" >> "$GITHUB_OUTPUT"
exit 0
fi
ver="${latest#v}"
major="${ver%%.*}"
rest="${ver#*.}"
minor="${rest%%.*}"
patch="${rest#*.}"
case "$BUMP" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
*)
echo "unknown bump: $BUMP" >&2
exit 1
;;
esac
next="v${major}.${minor}.${patch}"
echo "Latest stable tag: $latest"
echo "Bump: $BUMP → $next"
echo "tag=$next" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
cache: true
- name: Verify modules
run: |
go mod download
go mod verify
- name: Test
run: go test ./... -count=1 -timeout=10m
- name: Build release binaries
env:
CGO_ENABLED: "0"
VERSION: ${{ steps.version.outputs.tag }}
run: |
set -euo pipefail
MODULE=github.com/LAA-Software-Engineering/agentic-control-plane/internal/cli
LDFLAGS="-s -w -X ${MODULE}.Version=${VERSION}"
mkdir -p dist work/linux-amd64 work/linux-arm64 work/darwin-amd64 work/darwin-arm64 work/windows-amd64
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="$LDFLAGS" -o work/linux-amd64/agentctl ./cmd/agentctl
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="$LDFLAGS" -o work/linux-arm64/agentctl ./cmd/agentctl
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags="$LDFLAGS" -o work/darwin-amd64/agentctl ./cmd/agentctl
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="$LDFLAGS" -o work/darwin-arm64/agentctl ./cmd/agentctl
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="$LDFLAGS" -o work/windows-amd64/agentctl.exe ./cmd/agentctl
(cd work/linux-amd64 && tar czf "../../dist/agentctl-${VERSION}-linux-amd64.tar.gz" agentctl)
(cd work/linux-arm64 && tar czf "../../dist/agentctl-${VERSION}-linux-arm64.tar.gz" agentctl)
(cd work/darwin-amd64 && tar czf "../../dist/agentctl-${VERSION}-darwin-amd64.tar.gz" agentctl)
(cd work/darwin-arm64 && tar czf "../../dist/agentctl-${VERSION}-darwin-arm64.tar.gz" agentctl)
(cd work/windows-amd64 && zip -q "../../dist/agentctl-${VERSION}-windows-amd64.zip" agentctl.exe)
(cd dist && sha256sum *.tar.gz *.zip | tee SHA256SUMS.txt)
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
target_commitish: ${{ github.sha }}
files: |
dist/*.tar.gz
dist/*.zip
dist/SHA256SUMS.txt
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}