-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (89 loc) · 3.35 KB
/
release.yml
File metadata and controls
104 lines (89 loc) · 3.35 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
name: Release
on:
push:
tags:
- "v*"
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.25"
cache: true
- name: Run tests before release
run: go test -v -coverprofile=coverage.txt ./...
- name: Check test coverage
run: |
coverage=$(go tool cover -func=coverage.txt | grep total | awk '{print $3}' | sed 's/%//')
echo "Coverage: ${coverage}%"
if (( $(echo "$coverage < 75" | bc -l) )); then
echo "ERROR: Coverage is below 75%"
exit 1
fi
- name: Run security checks
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/golang/vuln/cmd/govulncheck@latest
echo "=== Running gosec ===" >> security-evidence.txt
gosec -fmt json -out gosec-results.json ./... || true
echo "=== Running govulncheck ===" >> security-evidence.txt
govulncheck ./... >> security-evidence.txt 2>&1 || true
echo "=== Test coverage ===" >> security-evidence.txt
go tool cover -func=coverage.txt >> security-evidence.txt
- name: Create Release Notes
id: release_notes
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Extract changelog for this version
CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | head -n -1)
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.release_notes.outputs.version }}
body: ${{ steps.release_notes.outputs.changelog }}
draft: false
prerelease: ${{ contains(steps.release_notes.outputs.version, 'alpha') || contains(steps.release_notes.outputs.version, 'beta') }}
- name: Upload security evidence
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./security-evidence.txt
asset_name: security-evidence.txt
asset_content_type: text/plain
- name: Upload coverage report
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./coverage.txt
asset_name: coverage.txt
asset_content_type: text/plain
- name: Upload gosec results
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gosec-results.json
asset_name: gosec-results.json
asset_content_type: application/json