From a982bd1a77ae7747ab780fa67c4883bfb30d35d8 Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Fri, 2 Oct 2026 15:47:15 +0100 Subject: [PATCH 1/3] Require checks before publishing the extension --- .github/workflows/publish.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 225cb0d..3b7b970 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,7 +6,11 @@ on: - 'v*' jobs: + checks: + uses: ./.github/workflows/test.yml + publish: + needs: checks runs-on: ubuntu-latest steps: From 00fd1f4fe7bcb840ed2e693504e211a40068465a Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Sun, 4 Oct 2026 15:33:00 +0100 Subject: [PATCH 2/3] Publish the extension artifact produced by checks Co-authored-by: Codex --- .github/workflows/publish.yml | 29 +++-------------------------- .github/workflows/test.yml | 7 +++++++ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4b05d7c..060a7eb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,44 +14,21 @@ jobs: 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c63c6f7..da70cb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,3 +63,10 @@ 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 From c7a9490ddb33d8ad9ed7aa3b02726bae72824d2f Mon Sep 17 00:00:00 2001 From: Ricardo Costa Date: Tue, 6 Oct 2026 23:17:50 +0100 Subject: [PATCH 3/3] Create release pull requests before tagging Co-authored-by: Codex --- .github/workflows/test.yml | 1 + CONTRIBUTING.md | 13 ++++- release.sh | 117 +++++++++++++++++++++++++++++-------- 3 files changed, 105 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da70cb3..1f39cad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,3 +70,4 @@ jobs: name: liquid-java-vsix path: client/liquid-java.vsix if-no-files-found: error + retention-days: 1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c73eb4..10f12bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``` +After the pull request passes Checks and is merged, create and push its release tag from `main`: + +```bash +./release.sh --tag +``` + +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: diff --git a/release.sh b/release.sh index db21e99..1b32114 100755 --- a/release.sh +++ b/release.sh @@ -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"