-
-
Notifications
You must be signed in to change notification settings - Fork 5
151 lines (134 loc) · 4.46 KB
/
Copy pathrelease.yml
File metadata and controls
151 lines (134 loc) · 4.46 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
# ctx Release Pipeline — Multi-platform binaries
# Triggers on version tags (v*). Builds for 5 platforms, creates GitHub Release.
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Version tag (e.g. v0.14.0)"
required: true
permissions: {}
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.26"
jobs:
release:
name: Build & Release
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
ext: .exe
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: go/go.sum
- name: Determine version
id: version
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "Building version: ${TAG}"
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
working-directory: go
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
BINARY="../ctx-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}"
go build \
-trimpath \
-ldflags="-s -w \
-X main.version=${{ steps.version.outputs.tag }} \
-X main.commit=${{ github.sha }} \
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o "${BINARY}" \
./cmd/ctx/
echo "Built: ${BINARY} ($(du -h "${BINARY}" | cut -f1))"
- name: Upload artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ctx-${{ matrix.goos }}-${{ matrix.goarch }}
path: ctx-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.ext }}
retention-days: 30
publish:
name: Publish Release
runs-on: ubuntu-latest
needs: [release]
permissions:
contents: write
steps:
- name: Checkout (with tags)
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist/
merge-multiple: true
- name: Determine version
id: version
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Extract tag annotation as release body
id: notes
run: |
TAG="${{ steps.version.outputs.tag }}"
# Extract tag annotation (strips signature block, keeps message body)
TAG_MSG=$(git tag -l --format='%(contents:subject)%0a%0a%(contents:body)' "$TAG")
if [ -z "$TAG_MSG" ] || [ "$TAG_MSG" = $'\n\n' ]; then
TAG_MSG="Release $TAG"
fi
{
echo "body<<RELEASE_NOTES_EOF"
echo "$TAG_MSG"
echo ""
echo "## Installation"
echo ""
echo "**With Go:**"
echo '```bash'
echo "go install github.com/GottZ/ctx/cmd/ctx@${TAG}"
echo '```'
echo ""
echo "**Binary download:**"
echo "Download the binary for your platform, make it executable, move to PATH:"
echo '```bash'
echo "chmod +x ctx-*"
echo "sudo mv ctx-* /usr/local/bin/ctx"
echo '```'
echo "RELEASE_NOTES_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ctx ${{ steps.version.outputs.tag }}
generate_release_notes: false
files: dist/*
body: ${{ steps.notes.outputs.body }}