Skip to content
Merged
3 changes: 3 additions & 0 deletions .github/workflows/_rust-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ jobs:
with:
token: ${{ steps.generate_token.outputs.token }}

- name: Rewrite SSH to HTTPS for public deps
run: git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"

- name: Install cross-compilation tools
if: runner.os == 'Linux'
env:
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
outputs:
image-resize: ${{ steps.filter.outputs.image-resize }}
iii-lsp: ${{ steps.filter.outputs.iii-lsp }}
iii-lsp-vscode: ${{ steps.filter.outputs.iii-lsp-vscode }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
Expand All @@ -28,6 +29,8 @@ jobs:
- 'image-resize/**'
iii-lsp:
- 'iii-lsp/**'
iii-lsp-vscode:
- 'iii-lsp-vscode/**'

image-resize:
name: "image-resize: Test, Format, Lint"
Expand Down Expand Up @@ -87,3 +90,24 @@ jobs:

- name: Run tests
run: cargo test --all-features

iii-lsp-vscode:
name: "iii-lsp-vscode: Lint"
needs: changes
if: needs.changes.outputs.iii-lsp-vscode == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: iii-lsp-vscode
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Package check (dry run)
run: npx @vscode/vsce package --out tmp.vsix && rm -f tmp.vsix
50 changes: 39 additions & 11 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
type: choice
options:
- image-resize
- iii-lsp
- iii-lsp-vscode
bump:
description: 'Version bump type'
required: true
Expand Down Expand Up @@ -52,8 +54,8 @@ jobs:
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.III_CI_APP_ID }}
private-key: ${{ secrets.III_CI_APP_PRIVATE_KEY }}
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -62,6 +64,7 @@ jobs:
token: ${{ steps.generate_token.outputs.token }}

- name: Pre-flight checks
id: preflight
env:
WORKER: ${{ inputs.worker }}
run: |
Expand All @@ -71,8 +74,12 @@ jobs:
exit 1
fi

if [[ ! -f "$WORKER/Cargo.toml" ]]; then
echo "::error::$WORKER/Cargo.toml not found"
if [[ -f "$WORKER/Cargo.toml" ]]; then
echo "manifest_type=cargo" >> "$GITHUB_OUTPUT"
elif [[ -f "$WORKER/package.json" ]]; then
echo "manifest_type=node" >> "$GITHUB_OUTPUT"
else
echo "::error::No Cargo.toml or package.json found in $WORKER/"
exit 1
fi

Expand Down Expand Up @@ -140,7 +147,16 @@ jobs:
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi

current=$(read_cargo_version "$WORKER/Cargo.toml")
read_node_version() {
jq -r '.version' "$1"
}

MANIFEST_TYPE="${{ steps.preflight.outputs.manifest_type }}"
if [[ "$MANIFEST_TYPE" == "cargo" ]]; then
current=$(read_cargo_version "$WORKER/Cargo.toml")
else
current=$(read_node_version "$WORKER/package.json")
fi
new_ver=$(bump_version "$current" "$WORKER" "$BUMP")

if [[ "$DRY_RUN" == "true" ]]; then
Expand All @@ -159,24 +175,36 @@ jobs:
NEW_VERSION: ${{ steps.versions.outputs.version }}
WORKER: ${{ inputs.worker }}
run: |
sed -i "0,/^version = \".*\"/{s/^version = \".*\"/version = \"${NEW_VERSION}\"/}" "${WORKER}/Cargo.toml"
echo "Updated ${WORKER}/Cargo.toml to ${NEW_VERSION}"
MANIFEST_TYPE="${{ steps.preflight.outputs.manifest_type }}"
if [[ "$MANIFEST_TYPE" == "cargo" ]]; then
sed -i "0,/^version = \".*\"/{s/^version = \".*\"/version = \"${NEW_VERSION}\"/}" "${WORKER}/Cargo.toml"
echo "Updated ${WORKER}/Cargo.toml to ${NEW_VERSION}"
else
jq --arg v "$NEW_VERSION" '.version = $v' "${WORKER}/package.json" > "${WORKER}/package.json.tmp"
mv "${WORKER}/package.json.tmp" "${WORKER}/package.json"
echo "Updated ${WORKER}/package.json to ${NEW_VERSION}"
fi

- name: Validate manifest update
if: inputs.dry_run != true
env:
NEW_VERSION: ${{ steps.versions.outputs.version }}
WORKER: ${{ inputs.worker }}
run: |
actual=$(grep '^version = ' "${WORKER}/Cargo.toml" | head -n1 | cut -d'"' -f2)
MANIFEST_TYPE="${{ steps.preflight.outputs.manifest_type }}"
if [[ "$MANIFEST_TYPE" == "cargo" ]]; then
actual=$(grep '^version = ' "${WORKER}/Cargo.toml" | head -n1 | cut -d'"' -f2)
else
actual=$(jq -r '.version' "${WORKER}/package.json")
fi
if [[ "$actual" != "$NEW_VERSION" ]]; then
echo "::error::${WORKER}/Cargo.toml version mismatch: expected ${NEW_VERSION}, got ${actual}"
echo "::error::Manifest version mismatch: expected ${NEW_VERSION}, got ${actual}"
exit 1
fi
echo "Validated ${WORKER}/Cargo.toml version: ${actual}"
echo "Validated manifest version: ${actual}"

- name: Update registry
if: inputs.dry_run != true
if: inputs.dry_run != true && inputs.worker != 'iii-lsp-vscode'
env:
NEW_VERSION: ${{ steps.versions.outputs.version }}
WORKER: ${{ inputs.worker }}
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/release-lsp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Release LSP

on:
push:
tags:
- 'iii-lsp/v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., iii-lsp/v1.0.0)'
required: true
type: string

permissions:
contents: write

concurrency:
group: release-iii-lsp-${{ github.ref }}
cancel-in-progress: false

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
is_prerelease: ${{ steps.meta.outputs.is_prerelease }}
dry_run: ${{ steps.meta.outputs.dry_run }}
steps:
- name: Resolve tag
id: resolve
run: |
TAG="${{ inputs.tag || github.ref_name }}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"

- name: Extract metadata from tag
id: meta
env:
TAG: ${{ steps.resolve.outputs.tag }}
run: |
VERSION="${TAG#iii-lsp/v}"

if [[ "$VERSION" =~ -dry-run\.[0-9]+$ ]]; then
echo "dry_run=true" >> "$GITHUB_OUTPUT"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
elif [[ "$VERSION" =~ -([a-z]+)\.[0-9]+$ ]]; then
echo "dry_run=false" >> "$GITHUB_OUTPUT"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "dry_run=false" >> "$GITHUB_OUTPUT"
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi

echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "::notice::iii-lsp release -- tag=$TAG version=$VERSION"

create-release:
name: Create GitHub Release
needs: [setup]
if: needs.setup.outputs.dry_run != 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ steps.generate_token.outputs.token }}
tag_name: ${{ needs.setup.outputs.tag }}
name: iii-lsp ${{ needs.setup.outputs.version }}
draft: false
prerelease: ${{ needs.setup.outputs.is_prerelease == 'true' }}
generate_release_notes: true

binary-build:
name: Binary Release
needs: [setup, create-release]
if: ${{ !failure() && !cancelled() }}
uses: ./.github/workflows/_rust-binary.yml
with:
bin_name: iii-lsp
manifest_path: iii-lsp/Cargo.toml
tag_name: ${{ needs.setup.outputs.tag }}
is_prerelease: ${{ needs.setup.outputs.is_prerelease == 'true' }}
skip_create_release: true
dry_run: ${{ needs.setup.outputs.dry_run == 'true' }}
secrets:
GH_APP_ID: ${{ secrets.GH_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
109 changes: 109 additions & 0 deletions .github/workflows/release-vscode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Release VSCode Extension

on:
push:
tags:
- 'iii-lsp-vscode/v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., iii-lsp-vscode/v1.0.0)'
required: true
type: string

permissions:
contents: write

concurrency:
group: release-vscode-${{ github.ref }}
cancel-in-progress: false

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
is_prerelease: ${{ steps.meta.outputs.is_prerelease }}
dry_run: ${{ steps.meta.outputs.dry_run }}
steps:
- name: Resolve tag
id: resolve
run: |
TAG="${{ inputs.tag || github.ref_name }}"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"

- name: Extract metadata from tag
id: meta
env:
TAG: ${{ steps.resolve.outputs.tag }}
run: |
VERSION="${TAG#iii-lsp-vscode/v}"

if [[ "$VERSION" =~ -dry-run\.[0-9]+$ ]]; then
echo "dry_run=true" >> "$GITHUB_OUTPUT"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
elif [[ "$VERSION" =~ -([a-z]+)\.[0-9]+$ ]]; then
echo "dry_run=false" >> "$GITHUB_OUTPUT"
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "dry_run=false" >> "$GITHUB_OUTPUT"
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi

echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "::notice::iii-lsp-vscode release -- tag=$TAG version=$VERSION"

publish:
name: Package & Publish
needs: [setup]
runs-on: ubuntu-latest
defaults:
run:
working-directory: iii-lsp-vscode
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
token: ${{ steps.generate_token.outputs.token }}

- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Package VSIX
run: npx @vscode/vsce package --out iii-lsp-${{ needs.setup.outputs.version }}.vsix

- name: Publish to VS Code Marketplace
if: needs.setup.outputs.dry_run != 'true'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx @vscode/vsce publish --pat "$VSCE_PAT"

- name: Publish to OpenVSX
if: needs.setup.outputs.dry_run != 'true'
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: npx ovsx publish iii-lsp-${{ needs.setup.outputs.version }}.vsix --pat "$OVSX_PAT"

- name: Upload VSIX to GitHub Release
if: needs.setup.outputs.dry_run != 'true'
uses: softprops/action-gh-release@v2
with:
token: ${{ steps.generate_token.outputs.token }}
tag_name: ${{ needs.setup.outputs.tag }}
name: iii-lsp-vscode ${{ needs.setup.outputs.version }}
draft: false
prerelease: ${{ needs.setup.outputs.is_prerelease == 'true' }}
generate_release_notes: true
files: iii-lsp-vscode/iii-lsp-${{ needs.setup.outputs.version }}.vsix
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ jobs:
id: generate_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.III_CI_APP_ID }}
private-key: ${{ secrets.III_CI_APP_PRIVATE_KEY }}
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -109,5 +109,5 @@ jobs:
skip_create_release: true
dry_run: ${{ needs.setup.outputs.dry_run == 'true' }}
secrets:
GH_APP_ID: ${{ secrets.III_CI_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.III_CI_APP_PRIVATE_KEY }}
GH_APP_ID: ${{ secrets.GH_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
Loading
Loading