Skip to content

Commit 15b6694

Browse files
chore: Automate extensions publishing (#70)
## Motivation This PR automates the publishing process for the LocalStack VS Code extension to both the Visual Studio Marketplace and Open VSX Registry. It introduces an automated workflow that can be triggered manually to publish the extension to both marketplaces, ensuring consistency and reducing manual effort. The extension is published to both marketplaces by default, but that can be overwritten using the GH CLI with inputs, see example below. Trigger: - Via GitHub UI (Actions tab → Select workflow → Re-run all jobs) - Via GitHub CLI: ` gh workflow run publish.yml -f publish_vscode_marketplace=true -f publish_ovsx=false --ref branch-name` The version is extracted from branch name (strips leading 'v' if present, since it is the convention so far for branch names) and validates it matches `package.json` version. ## Other changes Added Makefile targets for `lint` and `test` to provide a single source of truth for quality checks. ## Testing The workflows were tested by publishing version `1.2.5` with the `--pre-release` flag. Contrary to what I initially described in [DRG-69](https://linear.app/localstack/issue/DRG-69/automate-publishing-to-vs-marketplace-and-open-vsx), VS Code Marketplace pre-releases cannot have version suffixes (like `-beta.1`). They use the same version format as regular releases. The test pre-releases (version 1.2.5) are now live in both marketplaces but won't auto-update users unless they opted-in. These cannot be unlisted. :heavy_check_mark: Successfully tested the pre-release extension in VSCode: <img width="1661" height="425" alt="image" src="https://github.com/user-attachments/assets/019d3b5d-5b99-40af-81fa-80668ba780f0" /> Next release should be version `1.2.6` to supersede the pre-release versions. Will create the release `1.2.6 ` with a subsequent PR.
1 parent a049d34 commit 15b6694

File tree

7 files changed

+148
-18
lines changed

7 files changed

+148
-18
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 'Set Version from Branch'
2+
description: 'Sets VERSION environment variable from the current branch name'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Set version from branch name
8+
shell: bash
9+
run: |
10+
# GITHUB_HEAD_REF contains the source branch for PRs (e.g., "v1.2.5"), but is empty for pushes
11+
# GITHUB_REF_NAME contains the merge ref for PRs (e.g., "1/merge"), but the branch name for pushes
12+
# Prefer GITHUB_HEAD_REF when available to get the actual branch name
13+
if [ -n "$GITHUB_HEAD_REF" ]; then
14+
BRANCH_NAME="$GITHUB_HEAD_REF"
15+
else
16+
BRANCH_NAME="$GITHUB_REF_NAME"
17+
fi
18+
# Strip leading 'v' if present
19+
VERSION="${BRANCH_NAME#v}"
20+
21+
# Get version from package.json
22+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
23+
24+
# Verify versions match
25+
if [ "$VERSION" != "$PACKAGE_VERSION" ]; then
26+
echo "Error: Version mismatch!"
27+
echo " Branch version: $VERSION"
28+
echo " package.json version: $PACKAGE_VERSION"
29+
echo "Please ensure the branch name matches the version in package.json"
30+
exit 1
31+
fi
32+
33+
echo "VERSION=$VERSION" >> $GITHUB_ENV
34+
echo "Using version: $VERSION (from branch: $BRANCH_NAME)"

.github/workflows/build.yml

Lines changed: 2 additions & 5 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
@@ -54,6 +51,6 @@ jobs:
5451
env:
5552
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
5653
NODE_ENV: ci
57-
54+
5855
- name: Test
5956
run: xvfb-run -a npx vscode-test

.github/workflows/publish.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish Extension
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publish_vscode_marketplace:
7+
description: 'Publish to VS Marketplace'
8+
type: boolean
9+
default: true
10+
publish_ovsx:
11+
description: 'Publish to Open VSX'
12+
type: boolean
13+
default: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
publish-vscode-marketplace:
20+
name: Publish to VS Marketplace
21+
runs-on: ubuntu-latest
22+
if: ${{ inputs.publish_vscode_marketplace != false }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v5
27+
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
30+
with:
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Set version from branch name
37+
uses: ./.github/actions/set-version
38+
39+
- name: Publish to VS Marketplace
40+
run: make publish-marketplace
41+
env:
42+
VERSION: ${{ env.VERSION }}
43+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
44+
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
45+
NODE_ENV: production
46+
ANALYTICS_API_URL: https://analytics.localstack.cloud/v1/events
47+
48+
publish-ovsx:
49+
name: Publish to Open VSX
50+
runs-on: ubuntu-latest
51+
if: ${{ inputs.publish_ovsx != false }}
52+
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v5
56+
57+
- name: Setup Node
58+
uses: actions/setup-node@v4
59+
with:
60+
cache: npm
61+
62+
- name: Install dependencies
63+
run: npm ci
64+
65+
- name: Set version from branch name
66+
uses: ./.github/actions/set-version
67+
68+
- name: Publish to Open VSX
69+
run: make publish-ovsx
70+
env:
71+
VERSION: ${{ env.VERSION }}
72+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
73+
LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode
74+
NODE_ENV: production
75+
ANALYTICS_API_URL: https://analytics.localstack.cloud/v1/events

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.2.5 (2025-11-05) (pre-release)
4+
5+
- chore: Testing publishing from Github action
6+
37
## 1.2.4 (2025-10-13)
48

59
- chore: Update dependencies
@@ -77,4 +81,4 @@ Initial preview release.
7781

7882
- Add feature deploy Lambda to LocalStack
7983
- Add feature invoke Lambda in LocalStack
80-
- Add Python CodeLens for triggering deploy and invoke commands
84+
- Add Python CodeLens for triggering deploy and invoke commands

Makefile

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
.PHONY: vsix publish
1+
.PHONY: publish-ovsx publish-marketplace lint test
22

3-
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
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+
npx vscode-test
19+
20+
publish-marketplace:
21+
@echo "Publishing VS Code extension to VS Marketplace..."
22+
@echo "Verifying PAT..."
23+
npx vsce verify-pat localstack -p $(VSCE_PAT)
24+
npx vsce publish $(VERSION) -p $(VSCE_PAT) --no-update-package-json
25+
26+
publish-ovsx:
27+
@echo "Publishing VS Code extension to Open VSX..."
28+
@echo "Verifying PAT..."
29+
npx ovsx verify-pat localstack -p $(OVSX_PAT)
30+
npx ovsx publish --packageVersion $(VERSION) -p $(OVSX_PAT)
831

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

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "LocalStack",
44
"displayName": "LocalStack Toolkit",
55
"description": "LocalStack - Run locally, deploy globally!",
6-
"version": "1.2.4",
6+
"version": "1.2.5",
77
"engines": {
88
"node": ">=20",
99
"vscode": "^1.83.0"

0 commit comments

Comments
 (0)