Skip to content

Commit 11c1f45

Browse files
committed
Refactor release workflow indentation for improved readability
1 parent bcc6af6 commit 11c1f45

File tree

1 file changed

+150
-150
lines changed

1 file changed

+150
-150
lines changed

.github/workflows/release.yml

Lines changed: 150 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,155 @@
11
name: Auto Release and Publish
22

33
on:
4-
push:
5-
branches:
6-
- master
4+
push:
5+
branches:
6+
- master
77

88
jobs:
9-
release:
10-
runs-on: ubuntu-latest
11-
permissions:
12-
contents: write
13-
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0
19-
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: '20.x'
24-
25-
- name: Install dependencies
26-
run: npm install
27-
28-
- name: Determine version bump
29-
id: version
30-
run: |
31-
# Get the latest tag or default to 0.0.0
32-
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
33-
echo "Latest tag: $LATEST_TAG"
34-
35-
# Remove 'v' prefix if present
36-
CURRENT_VERSION=${LATEST_TAG#v}
37-
echo "Current version: $CURRENT_VERSION"
38-
39-
# Split version into components
40-
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
41-
MAJOR="${VERSION_PARTS[0]:-0}"
42-
MINOR="${VERSION_PARTS[1]:-0}"
43-
PATCH="${VERSION_PARTS[2]:-0}"
44-
45-
# Get commit messages since last tag
46-
if git describe --tags --abbrev=0 2>/dev/null; then
47-
COMMITS=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=%B)
48-
else
49-
COMMITS=$(git log --pretty=%B)
50-
fi
51-
52-
echo "Analyzing commits..."
53-
54-
# Check for version bump keywords
55-
if echo "$COMMITS" | grep -qi "MajorChange:"; then
56-
MAJOR=$((MAJOR + 1))
57-
MINOR=0
58-
PATCH=0
59-
BUMP_TYPE="major"
60-
echo "Major version bump detected"
61-
elif echo "$COMMITS" | grep -qi "MinorChange:"; then
62-
MINOR=$((MINOR + 1))
63-
PATCH=0
64-
BUMP_TYPE="minor"
65-
echo "Minor version bump detected"
66-
elif echo "$COMMITS" | grep -qi "Patch:\|Refactor:"; then
67-
PATCH=$((PATCH + 1))
68-
BUMP_TYPE="patch"
69-
echo "Patch version bump detected"
70-
else
71-
echo "No version bump keywords found, skipping release"
72-
echo "skip=true" >> $GITHUB_OUTPUT
73-
exit 0
74-
fi
75-
76-
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
77-
echo "New version: $NEW_VERSION"
78-
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
79-
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
80-
echo "skip=false" >> $GITHUB_OUTPUT
81-
82-
- name: Update package.json version
83-
if: steps.version.outputs.skip != 'true'
84-
run: |
85-
NEW_VERSION="${{ steps.version.outputs.version }}"
86-
npm version $NEW_VERSION --no-git-tag-version
87-
git config user.name "github-actions[bot]"
88-
git config user.email "github-actions[bot]@users.noreply.github.com"
89-
git add package.json package-lock.json
90-
git commit -m "chore: bump version to $NEW_VERSION [skip ci]" || echo "No changes to commit"
91-
92-
- name: Build extension
93-
if: steps.version.outputs.skip != 'true'
94-
run: |
95-
npm run compile
96-
97-
- name: Package extension
98-
if: steps.version.outputs.skip != 'true'
99-
run: |
100-
npm install -g @vscode/vsce
101-
vsce package
102-
103-
- name: Create Release
104-
if: steps.version.outputs.skip != 'true'
105-
id: create_release
106-
uses: actions/create-release@v1
107-
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109-
with:
110-
tag_name: v${{ steps.version.outputs.version }}
111-
release_name: Release v${{ steps.version.outputs.version }}
112-
body: |
113-
## Release v${{ steps.version.outputs.version }}
114-
115-
### Changes
116-
This is a ${{ steps.version.outputs.bump_type }} release.
117-
118-
### Installation
119-
Download the `.vsix` file below and install it in VS Code:
120-
1. Open VS Code
121-
2. Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)
122-
3. Type "Extensions: Install from VSIX"
123-
4. Select the downloaded `.vsix` file
124-
125-
Or install directly from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=RhinoSoftware.go-memory-visualizer)
126-
draft: false
127-
prerelease: false
128-
129-
- name: Upload Release Asset
130-
if: steps.version.outputs.skip != 'true'
131-
uses: actions/upload-release-asset@v1
132-
env:
133-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134-
with:
135-
upload_url: ${{ steps.create_release.outputs.upload_url }}
136-
asset_path: ./go-memory-visualizer-${{ steps.version.outputs.version }}.vsix
137-
asset_name: go-memory-visualizer-${{ steps.version.outputs.version }}.vsix
138-
asset_content_type: application/octet-stream
139-
140-
- name: Publish to VS Code Marketplace
141-
if: steps.version.outputs.skip != 'true' && github.event_name == 'push'
142-
env:
143-
VSCE_PAT: ${{ secrets.VSCE_PAT }}
144-
run: |
145-
if [ -n "$VSCE_PAT" ]; then
146-
vsce publish -p $VSCE_PAT
147-
echo "Published to VS Code Marketplace"
148-
else
149-
echo "VSCE_PAT not set, skipping marketplace publish"
150-
fi
151-
152-
- name: Push version update
153-
if: steps.version.outputs.skip != 'true'
154-
run: |
155-
git push origin master --follow-tags || echo "Failed to push, may need manual intervention"
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "20.x"
24+
25+
- name: Install dependencies
26+
run: npm install
27+
28+
- name: Determine version bump
29+
id: version
30+
run: |
31+
# Get the latest tag or default to 0.0.0
32+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
33+
echo "Latest tag: $LATEST_TAG"
34+
35+
# Remove 'v' prefix if present
36+
CURRENT_VERSION=${LATEST_TAG#v}
37+
echo "Current version: $CURRENT_VERSION"
38+
39+
# Split version into components
40+
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
41+
MAJOR="${VERSION_PARTS[0]:-0}"
42+
MINOR="${VERSION_PARTS[1]:-0}"
43+
PATCH="${VERSION_PARTS[2]:-0}"
44+
45+
# Get commit messages since last tag
46+
if git describe --tags --abbrev=0 2>/dev/null; then
47+
COMMITS=$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=%B)
48+
else
49+
COMMITS=$(git log --pretty=%B)
50+
fi
51+
52+
echo "Analyzing commits..."
53+
54+
# Check for version bump keywords
55+
if echo "$COMMITS" | grep -qi "MajorChange:"; then
56+
MAJOR=$((MAJOR + 1))
57+
MINOR=0
58+
PATCH=0
59+
BUMP_TYPE="major"
60+
echo "Major version bump detected"
61+
elif echo "$COMMITS" | grep -qi "MinorChange:"; then
62+
MINOR=$((MINOR + 1))
63+
PATCH=0
64+
BUMP_TYPE="minor"
65+
echo "Minor version bump detected"
66+
elif echo "$COMMITS" | grep -qi "Patch:\|Refactor:"; then
67+
PATCH=$((PATCH + 1))
68+
BUMP_TYPE="patch"
69+
echo "Patch version bump detected"
70+
else
71+
echo "No version bump keywords found, skipping release"
72+
echo "skip=true" >> $GITHUB_OUTPUT
73+
exit 0
74+
fi
75+
76+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
77+
echo "New version: $NEW_VERSION"
78+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
79+
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
80+
echo "skip=false" >> $GITHUB_OUTPUT
81+
82+
- name: Update package.json version
83+
if: steps.version.outputs.skip != 'true'
84+
run: |
85+
NEW_VERSION="${{ steps.version.outputs.version }}"
86+
npm version $NEW_VERSION --no-git-tag-version
87+
git config user.name "github-actions[bot]"
88+
git config user.email "github-actions[bot]@users.noreply.github.com"
89+
git add package.json package-lock.json
90+
git commit -m "chore: bump version to $NEW_VERSION [skip ci]" || echo "No changes to commit"
91+
92+
- name: Build extension
93+
if: steps.version.outputs.skip != 'true'
94+
run: |
95+
npm run compile
96+
97+
- name: Package extension
98+
if: steps.version.outputs.skip != 'true'
99+
run: |
100+
npm install -g @vscode/vsce
101+
vsce package
102+
103+
- name: Create Release
104+
if: steps.version.outputs.skip != 'true'
105+
id: create_release
106+
uses: actions/create-release@v1
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
with:
110+
tag_name: v${{ steps.version.outputs.version }}
111+
release_name: Release v${{ steps.version.outputs.version }}
112+
body: |
113+
## Release v${{ steps.version.outputs.version }}
114+
115+
### Changes
116+
This is a ${{ steps.version.outputs.bump_type }} release.
117+
118+
### Installation
119+
Download the `.vsix` file below and install it in VS Code:
120+
1. Open VS Code
121+
2. Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)
122+
3. Type "Extensions: Install from VSIX"
123+
4. Select the downloaded `.vsix` file
124+
125+
Or install directly from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=RhinoSoftware.go-memory-visualizer)
126+
draft: false
127+
prerelease: false
128+
129+
- name: Upload Release Asset
130+
if: steps.version.outputs.skip != 'true'
131+
uses: actions/upload-release-asset@v1
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
with:
135+
upload_url: ${{ steps.create_release.outputs.upload_url }}
136+
asset_path: ./go-memory-visualizer-${{ steps.version.outputs.version }}.vsix
137+
asset_name: go-memory-visualizer-${{ steps.version.outputs.version }}.vsix
138+
asset_content_type: application/octet-stream
139+
140+
- name: Publish to VS Code Marketplace
141+
if: steps.version.outputs.skip != 'true' && github.event_name == 'push'
142+
env:
143+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
144+
run: |
145+
if [ -n "$VSCE_PAT" ]; then
146+
vsce publish -p $VSCE_PAT
147+
echo "Published to VS Code Marketplace"
148+
else
149+
echo "VSCE_PAT not set, skipping marketplace publish"
150+
fi
151+
152+
- name: Push version update
153+
if: steps.version.outputs.skip != 'true'
154+
run: |
155+
git push origin master --follow-tags || echo "Failed to push, may need manual intervention"

0 commit comments

Comments
 (0)