-
Notifications
You must be signed in to change notification settings - Fork 1
214 lines (178 loc) · 6.48 KB
/
release.yml
File metadata and controls
214 lines (178 loc) · 6.48 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
default: 'v0.1.0'
jobs:
build:
name: Build binaries
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Linux
- goos: linux
goarch: amd64
suffix: ''
- goos: linux
goarch: arm64
suffix: ''
# macOS
- goos: darwin
goarch: amd64
suffix: ''
- goos: darwin
goarch: arm64
suffix: ''
# Windows
- goos: windows
goarch: amd64
suffix: '.exe'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup mvx
run: |
curl -fsSL https://raw.githubusercontent.com/gnodet/mvx/main/install-wrapper.sh | bash
./mvx setup
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_no_v=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
# Use CGO_ENABLED=1 for macOS to avoid security restrictions, 0 for others
CGO_ENABLED: ${{ matrix.goos == 'darwin' && '1' || '0' }}
run: |
BINARY_NAME="mvx-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.suffix }}"
./mvx go build \
-ldflags "-s -w -X main.Version=${{ steps.version.outputs.version_no_v }} -X main.Commit=${{ github.sha }} -X main.Date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o "dist/${BINARY_NAME}" \
.
# Create checksums
cd dist
sha256sum "${BINARY_NAME}" > "${BINARY_NAME}.sha256"
echo "Built: ${BINARY_NAME}"
ls -la "${BINARY_NAME}"*
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mvx-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
dist/mvx-${{ matrix.goos }}-${{ matrix.goarch }}*
retention-days: 1
release:
name: Create release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_no_v=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
find artifacts -name "mvx-*" -type f -exec cp {} release/ \;
# Create combined checksums file
cd release
cat *.sha256 > checksums.txt
echo "Release assets:"
ls -la
- name: Generate release notes
run: |
# Make sure the changelog script is executable
chmod +x ./scripts/generate-changelog.sh
# Get the current tag being released
CURRENT_TAG="${{ steps.version.outputs.version }}"
# Get the previous tag (excluding the current one)
# Sort tags by version and get the one before current
PREVIOUS_TAG=$(git tag -l 'v*' --sort=-version:refname | grep -v "^${CURRENT_TAG}$" | head -n 1)
# Generate the changelog section
if [ -n "$PREVIOUS_TAG" ]; then
echo "Generating changelog from $PREVIOUS_TAG to $CURRENT_TAG"
CHANGELOG=$(./scripts/generate-changelog.sh "$PREVIOUS_TAG" "$CURRENT_TAG")
else
echo "No previous tag found, using generic changelog"
CHANGELOG="## 🚀 What's New
This is the first release of mvx!"
fi
# Create the complete release notes
cat > release_notes.md << EOF
## mvx ${{ steps.version.outputs.version_no_v }}
$CHANGELOG
### 🚀 Installation
**Using the wrapper (recommended):**
\`\`\`bash
curl -fsSL https://raw.githubusercontent.com/gnodet/mvx/main/install-wrapper.sh | bash
./mvx version
\`\`\`
**Direct download:**
\`\`\`bash
# Linux x64
curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-linux-amd64 -o mvx
chmod +x mvx
# macOS x64
curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-darwin-amd64 -o mvx
chmod +x mvx
# Windows x64
curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/mvx-windows-amd64.exe -o mvx.exe
\`\`\`
### 📦 Assets
| Platform | Architecture | Binary | Checksum |
|----------|--------------|--------|----------|
| Linux | x64 | \`mvx-linux-amd64\` | \`mvx-linux-amd64.sha256\` |
| Linux | ARM64 | \`mvx-linux-arm64\` | \`mvx-linux-arm64.sha256\` |
| macOS | x64 | \`mvx-darwin-amd64\` | \`mvx-darwin-amd64.sha256\` |
| macOS | ARM64 | \`mvx-darwin-arm64\` | \`mvx-darwin-arm64.sha256\` |
| Windows | x64 | \`mvx-windows-amd64.exe\` | \`mvx-windows-amd64.exe.sha256\` |
### 🔐 Verification
Verify checksums:
\`\`\`bash
curl -fsSL https://github.com/gnodet/mvx/releases/download/${{ steps.version.outputs.version }}/checksums.txt
sha256sum -c checksums.txt
\`\`\`
EOF
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: mvx ${{ steps.version.outputs.version_no_v }}
body_path: release_notes.md
files: release/*
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}