-
Notifications
You must be signed in to change notification settings - Fork 15
184 lines (154 loc) · 7.17 KB
/
release.yml
File metadata and controls
184 lines (154 loc) · 7.17 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
name: Release
on:
push:
tags:
- 'v*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
permissions:
contents: write
pull-requests: read
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history for changelog generation
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build extension
run: npm run build
- name: Create zip package
run: npm run zip
- name: Generate SHA256 checksum
id: checksum
run: |
CHECKSUM=$(sha256sum arcify-extension.zip | cut -d ' ' -f 1)
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
echo "SHA256: $CHECKSUM" > checksum.txt
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release_notes
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
const fs = require('fs');
// Get the current tag and previous tag
const currentTag = context.ref.replace('refs/tags/', '');
const version = currentTag.replace(/^v/, ''); // Remove 'v' prefix if present
let previousTag;
try {
previousTag = execSync('git describe --tags --abbrev=0 HEAD^', { encoding: 'utf8' }).trim();
} catch (error) {
// If no previous tag exists, use the first commit
previousTag = execSync('git rev-list --max-parents=0 HEAD', { encoding: 'utf8' }).trim();
}
// Get commits between tags
const commits = execSync(`git log ${previousTag}..${currentTag} --pretty=format:"%h %s" --no-merges`, { encoding: 'utf8' }).trim();
// Read package.json for extension info
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const manifestJson = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
// Read checksum from file
let checksum = '';
try {
const checksumContent = fs.readFileSync('checksum.txt', 'utf8');
checksum = checksumContent.replace('SHA256: ', '').trim();
} catch (error) {
console.log('Warning: Could not read checksum.txt');
}
// Generate release notes
let releaseNotes = `# ${manifestJson.name} v${version}\n\n`;
releaseNotes += `${manifestJson.description}\n\n`;
if (commits) {
releaseNotes += `## 🚀 What's Changed\n\n`;
const commitLines = commits.split('\n');
// Categorize commits
const features = [];
const fixes = [];
const other = [];
commitLines.forEach(line => {
if (line.toLowerCase().includes('feat') || line.toLowerCase().includes('add')) {
features.push(line);
} else if (line.toLowerCase().includes('fix') || line.toLowerCase().includes('bug')) {
fixes.push(line);
} else {
other.push(line);
}
});
if (features.length > 0) {
releaseNotes += `### ✨ New Features\n`;
features.forEach(commit => {
const [hash, ...messageParts] = commit.split(' ');
releaseNotes += `- ${messageParts.join(' ')} (${hash})\n`;
});
releaseNotes += '\n';
}
if (fixes.length > 0) {
releaseNotes += `### 🐛 Bug Fixes\n`;
fixes.forEach(commit => {
const [hash, ...messageParts] = commit.split(' ');
releaseNotes += `- ${messageParts.join(' ')} (${hash})\n`;
});
releaseNotes += '\n';
}
if (other.length > 0) {
releaseNotes += `### 🔧 Other Changes\n`;
other.forEach(commit => {
const [hash, ...messageParts] = commit.split(' ');
releaseNotes += `- ${messageParts.join(' ')} (${hash})\n`;
});
releaseNotes += '\n';
}
}
// Add installation instructions
releaseNotes += `## 📦 Installation\n\n`;
releaseNotes += `### Chrome Web Store\n`;
releaseNotes += `*Coming soon - extension will be available on the Chrome Web Store*\n\n`;
releaseNotes += `### Manual Installation\n`;
releaseNotes += `1. Download \`arcify-extension.zip\` from the assets below\n`;
releaseNotes += `2. Extract the zip file\n`;
releaseNotes += `3. Open Chrome and go to \`chrome://extensions/\`\n`;
releaseNotes += `4. Enable "Developer mode" in the top right\n`;
releaseNotes += `5. Click "Load unpacked" and select the extracted folder\n\n`;
// Add file info
releaseNotes += `## 📋 File Information\n\n`;
releaseNotes += `| File | SHA256 Checksum |\n`;
releaseNotes += `|------|----------------|\n`;
releaseNotes += `| arcify-extension.zip | \`${checksum}\` |\n\n`;
// Add compatibility info
releaseNotes += `## 🔧 Compatibility\n\n`;
releaseNotes += `- **Chrome**: Version 88+ (Manifest V3 support required)\n`;
releaseNotes += `- **Edge**: Version 88+ (Chromium-based)\n`;
releaseNotes += `- **Brave**: Version 1.20+\n`;
releaseNotes += `- **Opera**: Version 74+\n\n`;
releaseNotes += `## 🛠️ Development\n\n`;
releaseNotes += `Built with:\n`;
releaseNotes += `- Vite.js for modern build tooling\n`;
releaseNotes += `- Chrome Extension Manifest V3\n`;
releaseNotes += `- ES6 Modules\n\n`;
releaseNotes += `---\n\n`;
releaseNotes += `**Full Changelog**: https://github.com/${{ github.repository }}/compare/${previousTag}...${currentTag}`;
return releaseNotes;
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
name: Arcify v${{ steps.version.outputs.version }}
body: ${{ steps.release_notes.outputs.result }}
draft: false
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'rc') }}
files: |
arcify-extension.zip
checksum.txt