From f55a4f4dc7eb3208f2f7b2bbc6fc4d10bd52d732 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Mon, 9 Dec 2024 09:01:48 +0900 Subject: [PATCH] Chores Signed-off-by: Sora Morimoto --- .github/workflows/main.yml | 47 +++++++++++++++++++++++++++----------- Makefile | 27 +++++----------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3f6537ee7..bba240275 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,8 +1,11 @@ name: Builds, tests & co on: - - push - - pull_request + push: + pull_request: + release: + types: + - published permissions: read-all @@ -25,7 +28,7 @@ jobs: - name: Set-up Node.js uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 23 check-latest: true - run: corepack enable @@ -38,14 +41,11 @@ jobs: - name: Run Biome checks run: yarn lint - - name: Build extension - run: opam exec -- make build-release - - - name: Package extension - run: yarn package + - name: Build and Package extension + run: opam exec -- make pkg - name: Generate artifact attestation - if: startsWith(github.ref, 'refs/tags') + if: github.event_name == 'release' uses: actions/attest-build-provenance@v2 with: subject-path: ocaml-platform.vsix @@ -59,26 +59,47 @@ jobs: - name: Test extension run: xvfb-run -a yarn test + release: + if: github.event_name == 'release' + needs: + - build-and-test + runs-on: ubuntu-latest + steps: + - name: Checkout tree + uses: actions/checkout@v4 + + - name: Set-up Node.js + uses: actions/setup-node@v4 + with: + node-version: 23 + check-latest: true + + - run: corepack enable + + - name: Install dependencies + run: yarn install --immutable + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ocaml-platform-${{ github.sha }} + - name: Publish extension to VSCode Marketplace - if: startsWith(github.ref, 'refs/tags') continue-on-error: true run: yarn deploy:vsce env: VSCE_PAT: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} - name: Publish extension to Open VSX Registry - if: startsWith(github.ref, 'refs/tags') continue-on-error: true run: yarn deploy:ovsx --pat "$OVSX_PAT" env: OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }} - name: Create release - if: startsWith(github.ref, 'refs/tags') continue-on-error: true uses: softprops/action-gh-release@v2 with: - draft: true files: ocaml-platform.vsix lint-opam: diff --git a/Makefile b/Makefile index 68ac63564..54d0f926c 100644 --- a/Makefile +++ b/Makefile @@ -21,33 +21,18 @@ create_switch: switch: create_switch deps ## Create an opam switch and install development dependencies .PHONY: build -build: ## Build the project - dune build src/vscode_ocaml_platform.bc.js - yarn workspace astexplorer build - yarn esbuild _build/default/src/vscode_ocaml_platform.bc.js \ - --bundle \ - --packages=bundle \ - --external:vscode \ - --outdir=dist \ - --platform=node \ - --target=es2022 \ - --sourcemap - -.PHONY: build-release -build-release: +build: clean ## Build the project dune build src/vscode_ocaml_platform.bc.js --profile=release yarn workspace astexplorer build yarn esbuild _build/default/src/vscode_ocaml_platform.bc.js \ --bundle \ - --packages=bundle \ --external:vscode \ + --minify \ --outdir=dist \ + --packages=bundle \ --platform=node \ --target=es2022 \ - --minify-whitespace \ - --minify-syntax \ - --sourcemap \ - --sources-content=false + --analyze .PHONY: test test: ## Run the unit tests @@ -57,7 +42,7 @@ test: ## Run the unit tests .PHONY: clean clean: ## Clean build artifacts and other generated files dune clean - rm -r dist/ + $(RM) -r dist .PHONY: doc doc: ## Generate odoc documentation @@ -73,7 +58,7 @@ watch: ## Watch for the filesystem and rebuild on every change dune build @all -w --terminal-persistence=clear-on-rebuild .PHONY: pkg -pkg: build-release # Builds and packages the extension for installment +pkg: build # Builds and packages the extension for installment yarn package .PHONY: install