Skip to content

Commit 85973c6

Browse files
authored
Merge pull request #2 from ketupia/seprate-build-release-worfklows
Separate build and release workflows
2 parents 0c01f70 + f5c0fa0 commit 85973c6

3 files changed

Lines changed: 116 additions & 53 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Extension
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
packages: read
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "18"
25+
cache: "npm"
26+
- name: Cache npm
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.npm
30+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-node-
33+
- name: Install dependencies
34+
run: npm ci
35+
- name: Run quality checks
36+
run: npm run quality
37+
- name: Build extension
38+
run: npm run build

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release Extension
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # Triggers on version tags like v0.0.1, v1.0.0, etc.
7+
8+
# Allow manual triggering of the workflow for exceptional cases, such as re-releasing a specific version.
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "The tag version to release (e.g., v1.0.0)"
13+
required: true
14+
reason:
15+
description: "Reason for manually triggering the release"
16+
required: false
17+
18+
permissions:
19+
contents: write
20+
packages: read
21+
22+
jobs:
23+
release:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.tag) || github.ref }}
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: "18"
34+
cache: "npm"
35+
- name: Ensure tag matches version in package.json
36+
run: |
37+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
38+
TAG_VERSION="${{ github.event.inputs.tag }}"
39+
else
40+
TAG_VERSION="${GITHUB_REF##*/}"
41+
fi
42+
PKG_VERSION=$(node -p "require('./package.json').version")
43+
if [ "v$PKG_VERSION" != "$TAG_VERSION" ]; then
44+
echo "::error::Tag ($TAG_VERSION) does not match package.json version (v$PKG_VERSION)"
45+
exit 1
46+
fi
47+
- name: Log manual release reason
48+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.reason != ''
49+
run: |
50+
echo "Manual release reason: ${{ github.event.inputs.reason }}"
51+
# Removed redundant npm cache step as caching is already handled by setup-node with 'cache: "npm"'.
52+
- name: Install dependencies
53+
run: npm ci
54+
- name: Run quality checks
55+
run: npm run quality
56+
- name: Build extension
57+
run: npm run build
58+
- name: Package extension
59+
run: npx @vscode/vsce package
60+
- name: Check VSIX exists
61+
run: |
62+
if ! ls *.vsix > /dev/null 2>&1; then
63+
echo "::error::VSIX package not found!"
64+
exit 1
65+
fi
66+
- name: Upload VSIX as artifact
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ash-studio-extension
70+
path: "*.vsix"
71+
retention-days: 30
72+
- name: Create Release
73+
uses: softprops/action-gh-release@v1
74+
with:
75+
files: "*.vsix"
76+
generate_release_notes: true
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)