-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (142 loc) · 5.32 KB
/
Copy pathrelease.yml
File metadata and controls
169 lines (142 loc) · 5.32 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
name: Release
on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version tag (e.g. v1.0.0, leave empty for automated numerical version)'
required: false
default: ''
permissions:
contents: write
jobs:
test:
name: Run Tests & Verification
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Run Linters
run: make lint
- name: Run Tests
run: make test
build-and-release:
name: Build & Release
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout Source (full history)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Determine Release Tag & Time
id: release_info
run: |
export TZ=Asia/Kolkata
DISPLAY_TIME=$(date +'%d %b %Y, %H:%M IST')
echo "DISPLAY_TIME=$DISPLAY_TIME" >> $GITHUB_OUTPUT
BASE_VER=$(grep -m1 '^VERSION' Makefile | cut -d'=' -f2 | tr -d ' ' | sed 's/^v//')
if [ -z "$BASE_VER" ]; then
BASE_VER="1.0.0"
fi
MAJOR_MINOR=$(echo "$BASE_VER" | cut -d'.' -f1,2)
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
TAG="${{ github.event.inputs.version }}"
[[ "$TAG" != v* ]] && TAG="v$TAG"
elif [ "${{ github.ref_type }}" = "tag" ]; then
TAG="${{ github.ref_name }}"
else
TAG="v${MAJOR_MINOR}.${{ github.run_number }}"
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT
- name: Build Binaries with Makefile
run: make build VERSION=${{ steps.release_info.outputs.TAG }}
- name: Generate SHA256 Checksums
run: |
cd builds
sha256sum DrivePulse_* > checksums.txt
cat checksums.txt
- name: Generate Structured Changelog
id: changelog
run: |
LAST_TAG=$(git describe --tags --exclude='latest' --abbrev=0 HEAD~1 2>/dev/null || echo "")
RANGE="HEAD"
if [ -n "$LAST_TAG" ]; then
RANGE="${LAST_TAG}..HEAD"
fi
FEATS=$(git log "$RANGE" --grep="^[Ff]eat" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
FIXES=$(git log "$RANGE" --grep="^[Ff]ix" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
CHORES=$(git log "$RANGE" --grep="^\([Cc]hore\|[Dd]ocs\|[Cc]i\|[Rr]efactor\|[Ss]tyle\|[Tt]est\)" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
OTHERS=$(git log "$RANGE" --invert-grep --grep="^\([Ff]eat\|[Ff]ix\|[Cc]hore\|[Dd]ocs\|[Cc]i\|[Rr]efactor\|[Ss]tyle\|[Tt]est\)" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
CL_FILE=$(mktemp)
{
echo "### 💡 Highlights"
echo "DrivePulse automated release build (${{ steps.release_info.outputs.TAG }})."
echo ""
if [ -n "$FEATS" ]; then
echo "### 🚀 Features & Enhancements"
echo "$FEATS"
echo ""
fi
if [ -n "$FIXES" ]; then
echo "### 🐛 Bug Fixes"
echo "$FIXES"
echo ""
fi
if [ -n "$CHORES" ]; then
echo "### 🧹 Maintenance & Chores"
echo "$CHORES"
echo ""
fi
if [ -n "$OTHERS" ]; then
echo "### 📋 Other Commits"
echo "$OTHERS"
echo ""
fi
if [ -n "$LAST_TAG" ]; then
echo "### 🔗 Full Changelog"
echo "https://github.com/${{ github.repository }}/compare/${LAST_TAG}...${{ steps.release_info.outputs.TAG }}"
echo ""
fi
} > "$CL_FILE"
{
echo "CHANGELOG<<EOF"
cat "$CL_FILE"
echo "EOF"
} >> "$GITHUB_OUTPUT"
rm -f "$CL_FILE"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_info.outputs.TAG }}
name: "DrivePulse Release #${{ github.run_number }} (${{ steps.release_info.outputs.TAG }})"
body: |
⚡ **DrivePulse Automated Release**
📅 **Built at:** ${{ steps.release_info.outputs.DISPLAY_TIME }}
${{ steps.changelog.outputs.CHANGELOG }}
### 📦 Artifacts & Integrity
Binary assets are attached below along with `checksums.txt` (SHA256).
files: |
builds/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update latest tag
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -fa latest -m "Update latest tag to ${{ steps.release_info.outputs.TAG }}"
git push origin latest --force