diff --git a/.github/actions/build-vsix/action.yml b/.github/actions/build-vsix/action.yml new file mode 100644 index 0000000..1bf6b48 --- /dev/null +++ b/.github/actions/build-vsix/action.yml @@ -0,0 +1,19 @@ +name: 'Build VSIX Package' +description: 'Builds the VS Code extension VSIX package' + +inputs: + version: + description: 'Version to build' + required: true + +runs: + using: composite + steps: + - name: Build VSIX package + shell: bash + run: make vsix + env: + VERSION: ${{ inputs.version }} + LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode + NODE_ENV: production + ANALYTICS_API_URL: https://analytics.localstack.cloud/v1/events diff --git a/.github/actions/set-version/action.yml b/.github/actions/set-version/action.yml new file mode 100644 index 0000000..9515fc1 --- /dev/null +++ b/.github/actions/set-version/action.yml @@ -0,0 +1,17 @@ +name: 'Set Version from Branch' +description: 'Sets VERSION environment variable from the current branch name' + +runs: + using: composite + steps: + - name: Set version from branch name + shell: bash + run: | + # Use GITHUB_HEAD_REF for PRs, GITHUB_REF_NAME for direct pushes + if [ -n "$GITHUB_HEAD_REF" ]; then + BRANCH_NAME="$GITHUB_HEAD_REF" + else + BRANCH_NAME="$GITHUB_REF_NAME" + fi + echo "VERSION=$BRANCH_NAME" >> $GITHUB_ENV + echo "Using version: $BRANCH_NAME" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b5139a..0dd9795 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,11 +24,8 @@ jobs: - name: Install dependencies run: npm ci - - name: Format - run: npx biome ci . - - name: Lint - run: npx eslint + run: make lint test: name: Test @@ -46,14 +43,8 @@ jobs: - name: Install dependencies run: npm ci - - name: Type check - run: npx tsc - - - name: Compile - run: npx vsce package + - name: Test + run: make test env: LOCALSTACK_WEB_AUTH_REDIRECT: https://app.localstack.cloud/redirect?name=VSCode NODE_ENV: ci - - - name: Test - run: xvfb-run -a npx vscode-test diff --git a/.github/workflows/publish-ovsx.yml b/.github/workflows/publish-ovsx.yml new file mode 100644 index 0000000..869e428 --- /dev/null +++ b/.github/workflows/publish-ovsx.yml @@ -0,0 +1,38 @@ +name: Publish to Open VSX + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + name: Publish to Open VSX + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Set version from branch name + uses: ./.github/actions/set-version + + - name: Build VSIX package + uses: ./.github/actions/build-vsix + with: + version: ${{ env.VERSION }} + + - name: Publish to Open VSX + run: make publish-ovsx + env: + VERSION: ${{ env.VERSION }} + OVSX_PAT: ${{ secrets.OVSX_PAT }} diff --git a/.github/workflows/publish-vs-marketplace.yml b/.github/workflows/publish-vs-marketplace.yml new file mode 100644 index 0000000..d976cdf --- /dev/null +++ b/.github/workflows/publish-vs-marketplace.yml @@ -0,0 +1,38 @@ +name: Publish to Visual Studio Marketplace + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + publish: + name: Publish to VS Marketplace + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Set version from branch name + uses: ./.github/actions/set-version + + - name: Build VSIX package + uses: ./.github/actions/build-vsix + with: + version: ${{ env.VERSION }} + + - name: Publish to VS Marketplace + run: make publish-marketplace + env: + VERSION: ${{ env.VERSION }} + VSCE_PAT: ${{ secrets.VSCE_PAT }} diff --git a/Makefile b/Makefile index 9d8e737..92eabe0 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,35 @@ -.PHONY: vsix publish +.PHONY: vsix publish publish-ovsx publish-marketplace lint test + +# VERSION can be set via environment variable or defaults to the version in package.json +VERSION ?= $(shell node -p "require('./package.json').version") + +lint: + @echo "Running format check..." + npx biome ci . + @echo "Running linter..." + npx eslint + +test: + @echo "Running type check..." + npx tsc + @echo "Compiling extension..." + npx vsce package + @echo "Running tests..." + xvfb-run -a npx vscode-test vsix: - @echo "Packaging VS Code extension into VSIX file..." - 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 - @hash=$$(git rev-parse --short HEAD); \ - mv localstack-1.0.0.vsix localstack-1.0.0-$$hash.vsix - -publish: - @echo "Publishing VS Code extension..." - 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 + @echo "Packaging VS Code extension into VSIX file (version: $(VERSION))..." + npx vsce package $(VERSION) --no-update-package-json + @echo "Created: localstack-$(VERSION).vsix" + +publish-marketplace: + @echo "Publishing VS Code extension to VS Marketplace..." + @echo "Verifying PAT..." + npx vsce verify-pat localstack -p $(VSCE_PAT) + npx vsce publish --pre-release $(VERSION) -p $(VSCE_PAT) --no-update-package-json + +publish-ovsx: + @echo "Publishing VS Code extension to Open VSX..." + @echo "Verifying PAT..." + npx ovsx verify-pat localstack -p $(OVSX_PAT) + npx ovsx publish localstack-$(VERSION).vsix -p $(OVSX_PAT)