Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 7 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,29 @@ on:
- 'v*'

jobs:
checks:
uses: ./.github/workflows/test.yml

publish:
needs: checks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The published VSIX is rebuilt differently from the one the checks tested. After needs: checks, the publish job builds again with JDK 20 (checks use 21), npm install instead of npm ci, and vsce package --no-dependencies instead of vsce package. So the shipped artifact isn't the one that passed: a lockfile drift, a JDK difference or a dependency-bundling difference would only show up in the release.

Suggest either aligning the steps (same JDK, npm ci, same vsce flags), or uploading the VSIX from the checks job as an artifact and publishing exactly that file.

(As the PR description says, requiring Checks on main is still a repo-settings step. See also the skipped-job note on #138, which affects that required check.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 00fd1f4: checks upload the validated VSIX, and both marketplaces publish that exact downloaded file without rebuilding. Workflow/artifact checks, packaged runtime checks, and extension installation passed.

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
- name: Download checked extension
uses: actions/download-artifact@v4
with:
java-version: 21
distribution: temurin
name: liquid-java-vsix

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Build Server JAR
working-directory: ./server
run: |
mvn -B -ntp clean package -DskipTests
mkdir -p ../client/server
cp target/language-server-liquidjava.jar ../client/server/

- name: Install dependencies and build
working-directory: ./client
run: |
npm install
npm run package

- name: Install vsce
run: npm install -g @vscode/vsce

- name: Package extension
working-directory: ./client
run: vsce package --no-dependencies --out liquid-java.vsix

- name: Publish to VS Code Marketplace
working-directory: ./client
run: vsce publish --packagePath liquid-java.vsix -p ${{ secrets.VSCE_TOKEN }}

- name: Publish to Open VSX Marketplace
working-directory: ./client
run: npx ovsx publish liquid-java.vsix --pat ${{ secrets.OVSX_TOKEN }}
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ jobs:
unzip -Z1 liquid-java.vsix > /tmp/liquid-java-vsix-files.txt
grep -Fx 'extension/dist/server/language-server-liquidjava.jar' /tmp/liquid-java-vsix-files.txt
grep -Fx 'extension/media/webview.js' /tmp/liquid-java-vsix-files.txt

- name: Upload checked extension
uses: actions/upload-artifact@v4
with:
name: liquid-java-vsix
path: client/liquid-java.vsix
if-no-files-found: error
retention-days: 1
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,26 @@ Use `./install.sh --skip-server` to package and install the extension without re

### Releasing

To create and push a git tag that will trigger the GitHub Actions workflow that automatically publishes the extension in both the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=AlcidesFonseca.liquid-java) and the [Open VSX Registry](https://open-vsx.org/extension/AlcidesFonseca/liquid-java), run the release script from the repository root:
Create a version bump pull request from `main` with the release script:

```bash
./release.sh
```

By default, the script bumps the patch version in [client/package.json](./client/package.json).
To release a manually bumped version instead, pass the version explicitly; it must match the version in [client/package.json](./client/package.json):
By default, this bumps the patch version in [client/package.json](./client/package.json). Pass a version to set it explicitly:

```bash
./release.sh <new-version>
```

After the pull request passes Checks and is merged, create and push its release tag from `main`:

```bash
./release.sh --tag <new-version>
```

The tag runs Checks again and publishes the verified extension artifact to the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=AlcidesFonseca.liquid-java) and the [Open VSX Registry](https://open-vsx.org/extension/AlcidesFonseca/liquid-java).

### Development Mode

To run the extension in development mode, follow these steps:
Expand Down
117 changes: 94 additions & 23 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,113 @@
#!/bin/bash
#!/usr/bin/env bash

VERSION=$1
set -euo pipefail

# check valid version format
if [ -n "$VERSION" ] && [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must be in format 1.2.3"
usage() {
echo "Usage: ./release.sh [VERSION] | ./release.sh --tag VERSION" >&2
}

MODE="pr"
if [[ "${1:-}" == "--tag" ]]; then
MODE="tag"
shift
fi

if [[ $# -gt 1 ]] || [[ "$MODE" == "tag" && $# -ne 1 ]]; then
usage
exit 1
fi

VERSION="${1:-}"
if [[ -n "$VERSION" && ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must be in format 1.2.3" >&2
exit 1
fi

# check current branch
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" != "main" ]; then
echo "Releases can only be created from the main branch (current: $CURRENT_BRANCH)"
if [[ "$CURRENT_BRANCH" != "main" ]]; then
echo "Releases must start from main (current: $CURRENT_BRANCH)" >&2
exit 1
fi

# bump patch version if no version provided
if [ -z "$VERSION" ]; then
(cd client && npm version patch --no-git-tag-version)
VERSION=$(node -p "require('./client/package.json').version")
if [[ -n "$(git status --porcelain)" ]]; then
echo "Releases require a clean working tree" >&2
exit 1
fi

# check if version present in package.json
if ! grep -q "\"version\": \"$VERSION\"" ./client/package.json; then
echo "Version $VERSION not found in package.json"
git pull --ff-only origin main
if [[ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]]; then
echo "Local main must match origin/main before releasing" >&2
exit 1
fi

# check if version tag already exists
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Release $VERSION already exists"
if [[ "$MODE" == "tag" ]]; then
CURRENT_VERSION=$(node -p "require('./client/package.json').version")
if [[ "$CURRENT_VERSION" != "$VERSION" ]]; then
echo "Version $VERSION is not the version on main ($CURRENT_VERSION)" >&2
exit 1
fi

if git rev-parse --quiet --verify "refs/tags/v$VERSION" >/dev/null; then
echo "Release $VERSION already exists" >&2
exit 1
fi
REMOTE_TAG=$(git ls-remote --tags origin "refs/tags/v$VERSION")
if [[ -n "$REMOTE_TAG" ]]; then
echo "Release $VERSION already exists" >&2
exit 1
fi

git tag -a "v$VERSION" origin/main -m "vscode-liquidjava $VERSION"
git push origin "refs/tags/v$VERSION"
exit 0
fi

if ! command -v gh >/dev/null 2>&1; then
echo "GitHub CLI (gh) is required to create the release pull request" >&2
exit 1
fi

git pull
git add .
if [[ -z "$VERSION" ]]; then
VERSION=$(node -e 'const [major, minor, patch] = require("./client/package.json").version.split(".").map(Number); console.log(`${major}.${minor}.${patch + 1}`)')
fi

CURRENT_VERSION=$(node -p "require('./client/package.json').version")
if [[ "$CURRENT_VERSION" == "$VERSION" ]]; then
echo "Version $VERSION is already on main; choose a new version" >&2
exit 1
fi

BRANCH="codex/release-$VERSION"
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
echo "Release branch $BRANCH already exists" >&2
exit 1
fi
REMOTE_BRANCH=$(git ls-remote --heads origin "refs/heads/$BRANCH")
if [[ -n "$REMOTE_BRANCH" ]]; then
echo "Release branch $BRANCH already exists" >&2
exit 1
fi

if git rev-parse --quiet --verify "refs/tags/v$VERSION" >/dev/null; then
echo "Release $VERSION already exists" >&2
exit 1
fi
REMOTE_TAG=$(git ls-remote --tags origin "refs/tags/v$VERSION")
if [[ -n "$REMOTE_TAG" ]]; then
echo "Release $VERSION already exists" >&2
exit 1
fi

git switch -c "$BRANCH"
(cd client && npm version "$VERSION" --no-git-tag-version >/dev/null)
git add client/package.json client/package-lock.json
git commit -m "Release $VERSION"
git tag -a "v$VERSION" -m "vscode-liquidjava $VERSION"
git push --set-upstream origin "$BRANCH"

gh pr create \
--base main \
--head "$BRANCH" \
--title "Release $VERSION" \
--body "Prepare version $VERSION for release. Merge this pull request after Checks pass, then run ./release.sh --tag $VERSION from main to publish."

git push
git push --tags
printf 'After the release pull request is merged, run ./release.sh --tag %s from main to publish.\n' "$VERSION"
Loading