-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (137 loc) · 5.47 KB
/
release.yml
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
name: Create Release and Publish to Marketplace
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Set API Key
run: |
echo "export const AMPLITUDE_API_KEY = '${{ secrets.AMPLITUDE_API_KEY }}';" > src/constants/apiKeys.ts
- name: Build
run: npm run compile
- name: Package Extension
run: npm run package
- name: Get version from package.json
id: get_version
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Generate Release Notes
id: release_notes
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
SECOND_LATEST_TAG=$(git describe --tags --abbrev=0 $LATEST_TAG^)
# Получаем список изменений и очищаем его
CHANGES=$(git log $SECOND_LATEST_TAG..$LATEST_TAG --pretty=format:"- %s")
# Удаляем экранированные переносы строк и "Changes:"
CLEAN_CHANGES=$(echo "$CHANGES" | sed 's/\\n/\n/g' | sed 's/^Changes://g')
# Определяем тип релиза
if echo "$CLEAN_CHANGES" | grep -q "security patch release"; then
PREFIX="*🔒 Security Update!*"
RELEASE_NOTE="This release contains important security updates."
else
PREFIX="*🚀 New Release!*"
RELEASE_NOTE=""
fi
# Формируем финальное сообщение для Telegram
cat << EOF > telegram_message.txt
$PREFIX
GeminiCommit _${LATEST_TAG}_
Changes:
$CLEAN_CHANGES
[Download from Marketplace](https://marketplace.visualstudio.com/items?itemName=VizzleTF.geminicommit)
Join our [community chat](https://t.me/gemini_commit) for discussions and support!
#vscode #geminicommit #update #git #ai #gemini #developer #tools #llm
EOF
echo "TELEGRAM_MSG<<EOF" >> $GITHUB_OUTPUT
cat telegram_message.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
if [ -n "$RELEASE_NOTE" ]; then
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_NOTE" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Changes:" >> $GITHUB_OUTPUT
echo "$CLEAN_CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "NOTES<<EOF" >> $GITHUB_OUTPUT
echo "Changes:" >> $GITHUB_OUTPUT
echo "$CLEAN_CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const { repo: { owner, repo }, sha } = context;
const tag = context.ref.substring(10); // remove 'refs/tags/'
console.log(`Creating release for version ${process.env.VERSION}`);
const release = await github.rest.repos.createRelease({
owner,
repo,
tag_name: tag,
name: `Release ${tag}`,
body: `${{ steps.release_notes.outputs.NOTES }}`,
draft: false,
prerelease: false
});
const vsixFile = `geminicommit-${process.env.VERSION}.vsix`;
console.log(`Looking for file: ${vsixFile}`);
if (fs.existsSync(vsixFile)) {
const asset = await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: release.data.id,
name: vsixFile,
data: fs.readFileSync(vsixFile)
});
console.log(`Asset uploaded: ${asset.data.browser_download_url}`);
} else {
console.error(`File not found: ${vsixFile}`);
core.setFailed(`VSIX file not found: ${vsixFile}`);
}
- name: Publish to Visual Studio Marketplace
env:
VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }}
run: npx vsce publish -p $VSCE_PAT
- name: Send Telegram Notification
if: success()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
format: markdown
message_file: telegram_message.txt
- name: Notify on Security Release
if: ${{ contains(steps.release_notes.outputs.NOTES, '🔒 Security Patch Release') }}
uses: actions/github-script@v7
with:
script: |
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Security Release v${process.env.VERSION} Published`,
body: `A new security patch release v${process.env.VERSION} has been published to address critical vulnerabilities.
Release Notes:
${{ steps.release_notes.outputs.NOTES }}
The extension has been automatically updated in the Visual Studio Marketplace.`,
labels: ['security']
});