-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (120 loc) · 4.83 KB
/
Copy pathrelease.yml
File metadata and controls
144 lines (120 loc) · 4.83 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
name: Release Extension(Manual)
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 1.0.0)'
required: true
type: string
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Validate version format
run: |
if [[ ! ${{ github.event.inputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Must be in format x.y.z"
exit 1
fi
- name: Compare versions
id: version_check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version.replace(/-snapshot$/, '')")
NEW_VERSION="${{ github.event.inputs.version }}"
if ! dpkg --compare-versions "$NEW_VERSION" ge "$CURRENT_VERSION"; then
echo "New version ($NEW_VERSION) must be greater than or equal to current version ($CURRENT_VERSION)"
exit 1
fi
- name: Update package.json version
run: |
VERSION="${{ github.event.inputs.version }}"
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" package.json
git add package.json
git commit -m "chore: update version to $VERSION"
git push
- name: Create and push tag
run: |
VERSION="${{ github.event.inputs.version }}"
TAG_NAME="v$VERSION"
# Check if tag exists
if ! git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
else
echo "Tag $TAG_NAME already exists, reusing it"
fi
- name: Verify version match
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
if [ "${{ github.event.inputs.version }}" != "$PKG_VERSION" ]; then
echo "Version mismatch: Input version (${{ github.event.inputs.version }}) does not match package.json version ($PKG_VERSION)"
exit 1
fi
- uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Prepare build directory
run: |
rm -rf build
mkdir -p build
- name: Install vsce
run: npm install -g @vscode/vsce
- name: Package extension
run: vsce package -o "build/thymelab-vscode-${{ github.event.inputs.version }}.vsix"
- name: Get Changes
id: get_changes
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGES=$(git log --pretty=format:"- %s")
else
CHANGES=$(git log --pretty=format:"- %s" ${PREV_TAG}..HEAD)
fi
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: build/thymelab-vscode-*.vsix
generate_release_notes: true
name: ThymeLab VSCode v${{ github.event.inputs.version }}
tag_name: v${{ github.event.inputs.version }}
body: |
## ThymeLab VSCode Extension v${{ github.event.inputs.version }}
### Installation Instructions
#### Method 1: Install from VSIX
1. Download the `thymelab-vscode-${{ github.event.inputs.version }}.vsix` file from this release
2. Open VS Code
3. Go to Extensions view (Ctrl+Shift+X)
4. Click on the '...' menu (Views and More Actions)
5. Select 'Install from VSIX...'
6. Choose the downloaded VSIX file
#### Method 2: Command Line Installation
```bash
code --install-extension thymelab-vscode-${{ github.event.inputs.version }}.vsix
```
### What's Changed
${{ steps.get_changes.outputs.changes }}
- name: Update to next snapshot version
run: |
CURRENT_VERSION="${{ github.event.inputs.version }}"
# Increment the last number and add -snapshot
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' OFS=.)-snapshot
sed -i "s/\"version\": \".*\"/\"version\": \"$NEW_VERSION\"/" package.json
git add package.json
git commit -m "chore: update version to $NEW_VERSION"
git push