This repository was archived by the owner on Feb 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
316 lines (259 loc) · 12.6 KB
/
Copy pathpre-release.yml
File metadata and controls
316 lines (259 loc) · 12.6 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
name: Pre-Release (Develop)
on:
push:
branches:
- develop
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/pre-release.yml"
workflow_dispatch:
inputs:
pre_release_type:
description: "Pre-release type"
required: true
default: "alpha"
type: choice
options:
- alpha
- beta
- rc
permissions:
contents: write
pull-requests: write
packages: write
actions: write
checks: write
issues: write
# Need to bypass branch protection for automated version commits
# This requires repository admin access or using a PAT
jobs:
test:
runs-on: windows-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Compile TypeScript
run: npm run compile
- name: Run tests
run: npm test
env:
CI: true
pre-release:
runs-on: ubuntu-latest
needs: test
outputs:
version: ${{ steps.release.outputs.version }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js 20.x
uses: actions/setup-node@v6
with:
node-version: 20.x
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Configure authentication for tag pushing
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
- name: Install standard-version
run: npm install -g standard-version
- name: Detect Pre-Release Type
id: detect-type
run: |
PRE_RELEASE_TYPE=""
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
PRE_RELEASE_TYPE="${{ github.event.inputs.pre_release_type }}"
echo "Manual pre-release type: $PRE_RELEASE_TYPE"
else
# Auto-detect based on commit messages or use alpha as default
RECENT_COMMITS=$(git log --oneline -10)
if echo "$RECENT_COMMITS" | grep -qi "beta\|release candidate\|rc"; then
PRE_RELEASE_TYPE="beta"
echo "🚀 Beta release detected from commits"
elif echo "$RECENT_COMMITS" | grep -qi "release\|stable"; then
PRE_RELEASE_TYPE="rc"
echo "🎯 Release candidate detected from commits"
else
PRE_RELEASE_TYPE="alpha"
echo "🧪 Alpha pre-release (default for develop)"
fi
fi
echo "pre-release-type=$PRE_RELEASE_TYPE" >> $GITHUB_OUTPUT
- name: Create Pre-Release
id: release
run: |
PRE_RELEASE_TYPE="${{ steps.detect-type.outputs.pre-release-type }}"
# Get current version and increment for pre-release
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"
# Generate pre-release version
TIMESTAMP=$(date +%Y%m%d%H%M)
SHORT_SHA=$(git rev-parse --short HEAD)
# Increment patch version and add pre-release identifier
npm version prerelease --preid="$PRE_RELEASE_TYPE.$TIMESTAMP.$SHORT_SHA" --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New pre-release version: $NEW_VERSION"
# Create tag locally (delete if exists)
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
echo "⚠️ Tag v$NEW_VERSION already exists, deleting it first"
git tag -d "v$NEW_VERSION"
fi
git tag "v$NEW_VERSION"
echo "📌 Created pre-release tag: v$NEW_VERSION"
# Stage package.json changes
git add package.json
echo "📝 Pre-release version updated"
- name: Generate Pre-Release Changelog
id: changelog
run: |
VERSION="${{ steps.release.outputs.version }}"
# Generate changelog from recent commits
echo "## 🧪 Pre-Release v$VERSION" > temp_changelog.md
echo "" >> temp_changelog.md
echo "**Pre-release from develop branch**" >> temp_changelog.md
echo "" >> temp_changelog.md
echo "### Recent Changes:" >> temp_changelog.md
# Get commits since last release
LAST_TAG=$(git describe --tags --abbrev=0 --match="v*" 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
echo "Generating changelog since $LAST_TAG..."
git log $LAST_TAG..HEAD --pretty=format:"- %s (%h)" --no-merges >> temp_changelog.md
else
echo "No previous tags found, using last 10 commits..."
git log --pretty=format:"- %s (%h)" --no-merges -10 >> temp_changelog.md
fi
echo "" >> temp_changelog.md
echo "" >> temp_changelog.md
echo "### 🔍 Testing Notes:" >> temp_changelog.md
echo "- This is a **pre-release** version from the develop branch" >> temp_changelog.md
echo "- Use for testing and validation purposes only" >> temp_changelog.md
echo "- Report issues at: https://github.com/mPokornyETM/vs-code-wincc-oa-projects-viewer/issues" >> temp_changelog.md
# Read changelog content
CHANGELOG_CONTENT=$(cat temp_changelog.md)
# Write to output (handle multiline content)
{
echo "changelog<<EOF"
echo "$CHANGELOG_CONTENT"
echo "EOF"
} >> $GITHUB_OUTPUT
rm temp_changelog.md
- name: Push Pre-Release Tag
run: |
VERSION="${{ steps.release.outputs.version }}"
# For pre-releases, we DON'T push version changes back to develop
# This avoids branch protection conflicts since we don't need to commit to develop
# The version bump is only in package.json for building the release artifact
echo "ℹ️ Pre-release version $VERSION is tag-only (not committed to develop)"
echo "📌 This prevents branch protection conflicts"
echo "✅ The develop branch package.json remains unchanged"
# Push tag only (no commit to develop needed)
if git ls-remote --tags origin "v$VERSION" | grep -q "v$VERSION"; then
echo "⚠️ Tag v$VERSION exists remotely, force pushing"
git push --force origin "v$VERSION"
else
git push origin "v$VERSION"
fi
echo "✅ Pushed pre-release tag: v$VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package Extension
run: |
npm install -g @vscode/vsce
vsce package
- name: Upload VSIX Artifact
uses: actions/upload-artifact@v5
with:
name: pre-release-${{ steps.release.outputs.version }}
path: "*.vsix"
retention-days: 14
- name: Create GitHub Pre-Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ steps.release.outputs.version }}"
name: "🧪 Pre-Release v${{ steps.release.outputs.version }}"
target_commitish: develop
body: |
${{ steps.changelog.outputs.changelog }}
### ⚠️ Pre-Release Warning
This is a **pre-release** version automatically generated from the `develop` branch.
**Use for testing purposes only:**
- ✅ Test new features and changes
- ✅ Validate functionality before production
- ❌ Not recommended for production use
### 📦 Installation
**Option 1: From VSIX (Recommended for testing)**
1. Download the `.vsix` file below
2. Open VS Code
3. Run `Extensions: Install from VSIX...`
4. Select the downloaded file
**Option 2: VS Code Marketplace (if published)**
- Search for "WinCC OA Projects" with pre-release enabled
### 🔄 Feedback
- [🐛 Report Issues](https://github.com/mPokornyETM/vs-code-wincc-oa-projects-viewer/issues)
- [💡 Suggest Features](https://github.com/mPokornyETM/vs-code-wincc-oa-projects-viewer/issues/new?template=feature_request.md)
files: "*.vsix"
draft: false
prerelease: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete Old Pre-Releases
run: |
echo "🧹 Cleaning up old pre-releases..."
# Get all pre-releases sorted by creation date (newest first)
# Use jq to sort by createdAt timestamp, not alphabetically
PRERELEASES=$(gh release list --limit 100 --json tagName,isPrerelease,createdAt --jq '[.[] | select(.isPrerelease == true)] | sort_by(.createdAt) | reverse | .[].tagName')
# Skip the first (latest) pre-release
OLD_PRERELEASES=$(echo "$PRERELEASES" | tail -n +2)
if [ -z "$OLD_PRERELEASES" ]; then
echo "✅ No old pre-releases to delete"
else
echo "🗑️ Deleting old pre-releases:"
for TAG in $OLD_PRERELEASES; do
echo " - Deleting $TAG"
gh release delete "$TAG" --yes --cleanup-tag || echo "⚠️ Failed to delete $TAG"
done
echo "✅ Old pre-releases cleaned up, kept only: v${{ steps.release.outputs.version }}"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-success:
runs-on: ubuntu-latest
needs: [pre-release]
if: success()
steps:
- name: Success Notification
run: |
echo "🧪 Pre-release v${{ needs.pre-release.outputs.version }} created successfully!"
echo "📦 Extension packaged and uploaded to GitHub Releases"
echo "🔍 Available for testing and validation"
echo "📝 Auto-generated from develop branch"
echo ""
echo "🔗 Pre-release URL: https://github.com/mPokornyETM/vs-code-wincc-oa-projects-viewer/releases/tag/v${{ needs.pre-release.outputs.version }}"
echo ""
echo "🧪 Test the pre-release and provide feedback!"