Skip to content

Commit e7330fa

Browse files
CI workflow to publish extension
1 parent a049d34 commit e7330fa

File tree

3 files changed

+118
-21
lines changed

3 files changed

+118
-21
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ jobs:
2424
- name: Install dependencies
2525
run: npm ci
2626

27-
- name: Format
28-
run: npx biome ci .
29-
3027
- name: Lint
31-
run: npx eslint
28+
run: make lint
3229

3330
test:
3431
name: Test
@@ -46,14 +43,8 @@ jobs:
4643
- name: Install dependencies
4744
run: npm ci
4845

49-
- name: Type check
50-
run: npx tsc
51-
52-
- name: Compile
53-
run: npx vsce package
46+
- name: Test
47+
run: make test
5448
env:
5549
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
5650
NODE_ENV: ci
57-
58-
- name: Test
59-
run: xvfb-run -a npx vscode-test

.github/workflows/publish.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Publish Extension
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish_vs_marketplace:
7+
description: 'Publish to VS Marketplace'
8+
required: true
9+
type: boolean
10+
default: false
11+
publish_open_vsx:
12+
description: 'Publish to Open VSX'
13+
required: true
14+
type: boolean
15+
default: false
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
publish:
22+
name: Build and Publish
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v5
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
cache: npm
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
37+
- name: Lint
38+
run: make lint
39+
40+
- name: Test
41+
run: make test
42+
env:
43+
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
44+
NODE_ENV: ci
45+
46+
- name: Set version from branch name
47+
run: |
48+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
49+
# Validate branch name is a valid version (only alphanumeric, dots, and hyphens)
50+
if ! echo "$BRANCH_NAME" | grep -Eq '^[a-zA-Z0-9.-]+$'; then
51+
echo "Error: Branch name '$BRANCH_NAME' is not a valid version format"
52+
echo "Version must contain only letters, numbers, dots, and hyphens"
53+
exit 1
54+
fi
55+
echo "VERSION=$BRANCH_NAME" >> $GITHUB_ENV
56+
echo "Using version: $BRANCH_NAME"
57+
58+
- name: Build VSIX package
59+
run: make vsix
60+
env:
61+
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
62+
NODE_ENV: production
63+
ANALYTICS_API_URL: https://analytics.localstack.cloud/v1/events
64+
65+
- name: Publish to VS Marketplace
66+
if: ${{ inputs.publish_vs_marketplace }}
67+
run: make publish-marketplace
68+
env:
69+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
70+
71+
- name: Publish to Open VSX
72+
if: ${{ inputs.publish_open_vsx }}
73+
run: make publish-ovsx
74+
env:
75+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
76+
77+
- name: Upload VSIX artifact
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: localstack-${{ env.VERSION }}.vsix
81+
path: localstack-${{ env.VERSION }}.vsix
82+
retention-days: 7

Makefile

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1-
.PHONY: vsix publish
1+
.PHONY: vsix publish publish-ovsx publish-marketplace lint test
2+
3+
# VERSION can be set via environment variable or defaults to the version in package.json
4+
VERSION ?= $(shell node -p "require('./package.json').version")
5+
6+
lint:
7+
@echo "Running format check..."
8+
npx biome ci .
9+
@echo "Running linter..."
10+
npx eslint
11+
12+
test:
13+
@echo "Running type check..."
14+
npx tsc
15+
@echo "Compiling extension..."
16+
npx vsce package
17+
@echo "Running tests..."
18+
xvfb-run -a npx vscode-test
219

320
vsix:
4-
@echo "Packaging VS Code extension into VSIX file..."
5-
LOCALSTACK_WEB_AUTH_REDIRECT=https://app.localstack.cloud/redirect?name=VSCode NODE_ENV=production ANALYTICS_API_URL=https://analytics.localstack.cloud/v1/events npx vsce package
6-
@hash=$$(git rev-parse --short HEAD); \
7-
mv localstack-1.0.0.vsix localstack-1.0.0-$$hash.vsix
8-
9-
publish:
10-
@echo "Publishing VS Code extension..."
11-
LOCALSTACK_WEB_AUTH_REDIRECT=https://app.localstack.cloud/redirect?name=VSCode NODE_ENV=production ANALYTICS_API_URL=https://analytics.localstack.cloud/v1/events npx vsce publish
21+
@echo "Packaging VS Code extension into VSIX file (version: $(VERSION))..."
22+
npx vsce package $(VERSION)
23+
@echo "Created: localstack-$(VERSION).vsix"
24+
25+
publish-marketplace:
26+
@echo "Publishing VS Code extension to VS Marketplace..."
27+
@echo "Verifying PAT..."
28+
npx vsce show localstack -p $(VSCE_PAT)
29+
npx vsce publish localstack-$(VERSION).vsix -p $(VSCE_PAT)
30+
31+
publish-ovsx:
32+
@echo "Publishing VS Code extension to Open VSX..."
33+
@echo "Verifying PAT..."
34+
npx ovsx verify-pat localstack -p $(OVSX_PAT)
35+
npx ovsx publish localstack-$(VERSION).vsix -p $(OVSX_PAT)

0 commit comments

Comments
 (0)