Skip to content

Commit a8b2499

Browse files
authored
Merge pull request #70 from rajbos/copilot/update-release-workflow
Add workflow_dispatch trigger for manual release creation from GitHub UI
2 parents dc38351 + 377c8cc commit a8b2499

2 files changed

Lines changed: 97 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
tags:
66
- 'v*' # Triggers on version tags like v1.0.0, v1.2.3, etc.
7+
workflow_dispatch: # Allows manual trigger from GitHub UI
8+
inputs:
9+
create_tag:
10+
description: 'Create tag from package.json version'
11+
required: false
12+
default: 'true'
13+
type: boolean
714

815
jobs:
916
release:
@@ -26,12 +33,16 @@ jobs:
2633
node-version: '20.x'
2734
cache: 'npm'
2835

29-
- name: Extract version from tag
30-
id: extract_version
36+
- name: Determine trigger type
37+
id: trigger_type
3138
run: |
32-
TAG_VERSION=${GITHUB_REF#refs/tags/v}
33-
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
34-
echo "Tag version: $TAG_VERSION"
39+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
40+
echo "is_manual=true" >> $GITHUB_OUTPUT
41+
echo "Triggered manually via workflow_dispatch"
42+
else
43+
echo "is_manual=false" >> $GITHUB_OUTPUT
44+
echo "Triggered by tag push"
45+
fi
3546
3647
- name: Extract version from package.json
3748
id: package_version
@@ -40,7 +51,55 @@ jobs:
4051
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
4152
echo "Package version: $PACKAGE_VERSION"
4253
43-
- name: Compare versions
54+
- name: Create tag for manual trigger
55+
if: steps.trigger_type.outputs.is_manual == 'true' && inputs.create_tag
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
VERSION="v${{ steps.package_version.outputs.package_version }}"
60+
echo "Creating tag: $VERSION"
61+
62+
# Check if tag already exists on remote using exit code
63+
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" >/dev/null 2>&1; then
64+
echo "❌ Tag $VERSION already exists on remote!"
65+
echo "Please update the version in package.json or delete the existing tag."
66+
exit 1
67+
fi
68+
69+
# Create and push the tag
70+
git config --local user.name "github-actions[bot]"
71+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
72+
git tag -a "$VERSION" -m "Release $VERSION"
73+
git push origin "$VERSION"
74+
75+
# Verify tag was created successfully on remote
76+
echo "Verifying tag was created on remote..."
77+
for i in {1..5}; do
78+
if git ls-remote --exit-code --tags origin "refs/tags/$VERSION" >/dev/null 2>&1; then
79+
echo "✅ Tag $VERSION created and verified on remote"
80+
exit 0
81+
fi
82+
echo "Waiting for tag to propagate (attempt $i/5)..."
83+
sleep 2
84+
done
85+
86+
echo "❌ Failed to verify tag creation on remote"
87+
exit 1
88+
89+
- name: Extract version from tag
90+
id: extract_version
91+
run: |
92+
if [ "${{ steps.trigger_type.outputs.is_manual }}" == "true" ]; then
93+
# For manual triggers, use package.json version
94+
TAG_VERSION="${{ steps.package_version.outputs.package_version }}"
95+
else
96+
# For tag triggers, extract from the tag
97+
TAG_VERSION=${GITHUB_REF#refs/tags/v}
98+
fi
99+
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
100+
echo "Release version: $TAG_VERSION"
101+
102+
- name: Verify version consistency
44103
run: |
45104
if [ "${{ steps.extract_version.outputs.tag_version }}" != "${{ steps.package_version.outputs.package_version }}" ]; then
46105
echo "❌ Version mismatch!"
@@ -51,6 +110,17 @@ jobs:
51110
fi
52111
echo "✅ Version check passed: ${{ steps.extract_version.outputs.tag_version }}"
53112
113+
- name: Determine tag name
114+
id: tag_name
115+
run: |
116+
if [ "${{ steps.trigger_type.outputs.is_manual }}" == "true" ]; then
117+
TAG_NAME="v${{ steps.extract_version.outputs.tag_version }}"
118+
else
119+
TAG_NAME="${{ github.ref_name }}"
120+
fi
121+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
122+
echo "Tag name: $TAG_NAME"
123+
54124
- name: Install dependencies
55125
run: npm ci
56126

@@ -109,8 +179,10 @@ jobs:
109179
env:
110180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111181
run: |
182+
echo "Creating release for tag: ${{ steps.tag_name.outputs.tag_name }}"
183+
112184
# Create release with notes and upload VSIX file
113-
gh release create ${{ github.ref_name }} \
185+
gh release create "${{ steps.tag_name.outputs.tag_name }}" \
114186
--title "Release ${{ steps.extract_version.outputs.tag_version }}" \
115187
--notes "${{ steps.release_notes.outputs.notes }}" \
116188
./${{ steps.vsix_filename.outputs.vsix_file }}
@@ -119,4 +191,4 @@ jobs:
119191
run: |
120192
echo "🎉 Release ${{ steps.extract_version.outputs.tag_version }} created successfully!"
121193
echo "📦 VSIX package: ${{ steps.vsix_filename.outputs.vsix_file }}"
122-
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
194+
echo "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_name.outputs.tag_name }}"

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,23 @@ The project includes comprehensive GitHub Actions workflows:
9191

9292
### Automated Releases
9393

94-
The project supports automated VSIX builds and releases when version tags are pushed:
94+
The project supports automated VSIX builds and releases through two methods:
95+
96+
#### Method 1: Manual Trigger via GitHub UI (Recommended)
97+
98+
1. Update the version in `package.json`
99+
2. Commit and push your changes to the main branch
100+
3. Go to GitHub Actions → Release workflow
101+
4. Click "Run workflow" and confirm
102+
103+
The workflow will automatically:
104+
- Create a tag based on the version in `package.json`
105+
- Run the full build pipeline (lint, type-check, compile, test)
106+
- Create a VSIX package
107+
- Create a GitHub release with auto-generated release notes
108+
- Attach the VSIX file as a release asset
109+
110+
#### Method 2: Tag-Based Release (Traditional)
95111

96112
1. Update the version in `package.json`
97113
2. Commit your changes

0 commit comments

Comments
 (0)