-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (102 loc) · 3.79 KB
/
Copy pathrelease-gate.yml
File metadata and controls
114 lines (102 loc) · 3.79 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
name: Release Gate
# Triggered by a version tag push (e.g. v0.0.12).
# All security checks must pass before a GitHub Release draft is created.
# To release: push a tag matching v* — this workflow does the rest.
#
# Usage:
# git tag v0.0.12
# git push origin v0.0.12
on:
push:
tags:
- 'v*'
permissions:
contents: write # needed to create a GitHub Release
security-events: write
jobs:
# ── Gate: unit tests ────────────────────────────────────────────────────────
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npm install --ignore-scripts
- run: npx vitest run
# ── Gate: ESLint security ───────────────────────────────────────────────────
eslint-security:
name: ESLint security
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npm install --ignore-scripts
- run: npx eslint .
# ── Gate: npm audit ─────────────────────────────────────────────────────────
npm-audit:
name: npm audit
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npm install --package-lock-only --ignore-scripts
- run: npm audit --audit-level=critical --omit=dev
# ── Gate: Gitleaks ──────────────────────────────────────────────────────────
gitleaks:
name: Gitleaks
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install Gitleaks
env:
GITLEAKS_VERSION: "8.21.2"
run: |
curl -sSfL \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /usr/local/bin gitleaks
- run: gitleaks detect --source . --config .gitleaks.toml --redact
# ── Publish: create GitHub Release draft ────────────────────────────────────
# Only runs if ALL gate jobs succeed.
create-release:
name: Create Release Draft
needs: [unit-tests, eslint-security, npm-audit, gitleaks]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Extract version from tag
id: tag
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release draft
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
name: "FoxSchema ${{ github.ref_name }}"
body: |
## FoxSchema ${{ github.ref_name }}
All security gates passed:
- ✅ Unit tests
- ✅ ESLint security rules
- ✅ npm audit (no Critical vulnerabilities)
- ✅ Gitleaks (no secrets detected)
> **Review this draft before publishing.** Edit the release notes above, then click "Publish release."