-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (106 loc) · 4.32 KB
/
release.yml
File metadata and controls
130 lines (106 loc) · 4.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
name: Release
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Archive build artifacts
run: |
cd public
zip -r ../website-build.zip .
cd ..
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: website-build.zip
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for changelog generation
- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=v${VERSION}" >> $GITHUB_OUTPUT
echo "Version: v${VERSION}"
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Generate changelog
id: changelog
run: |
# Get the latest tag (if exists)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
COMMIT_SHA="${{ github.sha }}"
SHORT_SHA=$(echo "$COMMIT_SHA" | cut -c1-7)
if [ -z "$LATEST_TAG" ]; then
# No previous tags, show last 10 commits
CHANGELOG=$(git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" -10)
FILES_CHANGED=$(git diff --stat ${COMMIT_SHA}~10..${COMMIT_SHA} --stat-width=80 | tail -1)
COMPARE_URL=""
PREVIOUS_TAG="Initial release"
else
# Get commits since last tag
CHANGELOG=$(git log ${LATEST_TAG}..${COMMIT_SHA} --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))")
FILES_CHANGED=$(git diff --stat ${LATEST_TAG}..${COMMIT_SHA} --stat-width=80 | tail -1)
COMPARE_URL="https://github.com/${{ github.repository }}/compare/${LATEST_TAG}...${SHORT_SHA}"
PREVIOUS_TAG="$LATEST_TAG"
fi
# Handle empty changelog
if [ -z "$CHANGELOG" ]; then
CHANGELOG="- ${{ github.event.head_commit.message }} ([$SHORT_SHA](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA))"
fi
# Output using multiline string
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "files_changed=$FILES_CHANGED" >> $GITHUB_OUTPUT
echo "compare_url=$COMPARE_URL" >> $GITHUB_OUTPUT
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}-${{ github.run_number }}
name: Release ${{ steps.version.outputs.version }} (Build ${{ github.run_number }})
body: |
## 🚀 Deployed to Netlify
- **Version:** ${{ steps.version.outputs.version }}
- **Build:** #${{ github.run_number }}
- **Commit:** [`${{ steps.changelog.outputs.short_sha }}`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
🌐 **[Launch Website →](${{ 'https://gear.dev/' }})**
---
### 📋 Changes
${{ steps.changelog.outputs.changes }}
### 📊 Files Changed
```
${{ steps.changelog.outputs.files_changed }}
```
### 🔍 Compare
${{ steps.changelog.outputs.compare_url && format('- [**{0}** → **{1}** — View full diff]({2})', steps.changelog.outputs.previous_tag, format('{0}-{1}', steps.version.outputs.version, github.run_number), steps.changelog.outputs.compare_url) || '*(Initial release — no previous version to compare)*' }}
files: redact-check-build.zip
draft: false
prerelease: false