Skip to content

Commit 5657540

Browse files
committed
Add GitHub Actions workflows for automated releases and version bumping
1 parent d333210 commit 5657540

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release Extension
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
# Only run if the PR was merged and has the "Release" label
12+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Release')
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Fetch full history for version tagging
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run linting
32+
run: npm run lint
33+
34+
- name: Build extension
35+
run: npm run build
36+
37+
- name: Run tests
38+
run: xvfb-run -a npm test
39+
40+
- name: Install vsce
41+
run: npm install -g @vscode/vsce
42+
43+
- name: Get version from package.json
44+
id: get-version
45+
run: |
46+
VERSION=$(node -p "require('./package.json').version")
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
echo "Extension version: $VERSION"
49+
50+
- name: Package extension
51+
run: vsce package
52+
53+
- name: Create GitHub Release
54+
uses: softprops/action-gh-release@v2
55+
id: create-release
56+
with:
57+
tag_name: v${{ steps.get-version.outputs.version }}
58+
name: Release v${{ steps.get-version.outputs.version }}
59+
body: |
60+
## Release v${{ steps.get-version.outputs.version }}
61+
62+
This release was automatically created from PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}
63+
64+
### Changes
65+
${{ github.event.pull_request.body }}
66+
files: |
67+
commitollama-${{ steps.get-version.outputs.version }}.vsix
68+
draft: false
69+
prerelease: false
70+
71+
- name: Publish to VS Code Marketplace
72+
env:
73+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
74+
run: vsce publish --pat $VSCE_PAT

.github/workflows/version-bump.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Version Bump
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
jobs:
17+
bump-version:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
cache: 'npm'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Configure Git
36+
run: |
37+
git config --local user.email "action@github.com"
38+
git config --local user.name "GitHub Action"
39+
40+
- name: Bump version
41+
run: |
42+
npm version ${{ github.event.inputs.version_type }} --no-git-tag-version
43+
NEW_VERSION=$(node -p "require('./package.json').version")
44+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
45+
46+
- name: Create Pull Request
47+
uses: peter-evans/create-pull-request@v6
48+
with:
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
commit-message: "chore: bump version to v${{ env.NEW_VERSION }}"
51+
title: "chore: bump version to v${{ env.NEW_VERSION }}"
52+
body: |
53+
## Version Bump
54+
55+
This PR automatically bumps the version to v${{ env.NEW_VERSION }}.
56+
57+
Type: ${{ github.event.inputs.version_type }}
58+
59+
To release this version:
60+
1. Review and merge this PR
61+
2. The release workflow will automatically trigger when this PR is merged (if it has the "Release" label)
62+
branch: version-bump-${{ env.NEW_VERSION }}
63+
labels: |
64+
Release
65+
delete-branch: true

0 commit comments

Comments
 (0)