Skip to content

Commit e78d852

Browse files
authored
Prepare release (#38)
- Switch to npm trusted publishing - Add publish release workflow - Update lerna
1 parent f1fb0e4 commit e78d852

5 files changed

Lines changed: 1817 additions & 1388 deletions

File tree

.github/workflows/publish-next.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to use for the release repo (default: default branch)'
8+
required: false
9+
type: string
10+
draft:
11+
description: 'Create draft GitHub release'
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
publish-release:
18+
uses: eclipse-glsp/glsp/.github/workflows/publish-release.yml@master
19+
with:
20+
release_repo: glsp-playwright
21+
branch: ${{ inputs.branch }}
22+
draft: ${{ inputs.draft }}

.github/workflows/publish.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: 'Publish to NPM'
2+
3+
on:
4+
workflow_run:
5+
workflows: ['CI']
6+
types:
7+
- completed
8+
branches: [master]
9+
workflow_call:
10+
inputs:
11+
ref:
12+
description: 'Git ref (branch, tag, or commit SHA) to checkout and publish'
13+
required: true
14+
type: string
15+
dist-tag:
16+
description: 'NPM dist-tag to use for publishing'
17+
required: false
18+
type: string
19+
default: 'next'
20+
workflow_dispatch:
21+
inputs:
22+
ref:
23+
description: 'Git ref (branch, tag, or commit SHA) to checkout and publish'
24+
required: true
25+
type: string
26+
dist-tag:
27+
description: 'NPM dist-tag to use for publishing'
28+
required: false
29+
type: choice
30+
options:
31+
- next
32+
- latest
33+
default: 'next'
34+
35+
permissions:
36+
contents: read
37+
id-token: write
38+
39+
jobs:
40+
publish:
41+
name: Build & Publish
42+
runs-on: ubuntu-22.04
43+
if: github.repository == 'eclipse-glsp/glsp-client' && (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (github.event.workflow_run.conclusion == 'success'))
44+
steps:
45+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
with:
47+
ref: ${{ inputs.ref || github.event.inputs.ref || github.event.workflow_run.head_commit.id || github.sha }}
48+
# Fetch all history for lerna to determine versions
49+
fetch-depth: 0
50+
51+
- name: Check for changes in "packages" or "examples" directory
52+
id: check_changes
53+
run: |
54+
DIST_TAG="${{ inputs.dist-tag || github.event.inputs.dist-tag || 'next' }}"
55+
# For 'next' dist-tag: check for changes when triggered by workflow_run or workflow_call
56+
# For 'latest' dist-tag or workflow_dispatch: always publish
57+
if [[ "$DIST_TAG" == "next" ]] && [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
58+
if git diff --name-only HEAD^ HEAD | grep -qE '^(packages|examples)'; then
59+
echo "should_publish=true" >> $GITHUB_OUTPUT
60+
else
61+
echo "should_publish=false" >> $GITHUB_OUTPUT
62+
fi
63+
else
64+
echo "should_publish=true" >> $GITHUB_OUTPUT
65+
fi
66+
67+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
68+
if: steps.check_changes.outputs.should_publish == 'true'
69+
with:
70+
node-version: 20.x
71+
registry-url: 'https://registry.npmjs.org'
72+
73+
- name: Build
74+
if: steps.check_changes.outputs.should_publish == 'true'
75+
run: yarn
76+
77+
- name: Publish to NPM
78+
if: steps.check_changes.outputs.should_publish == 'true'
79+
run: |
80+
DIST_TAG="${{ inputs.dist-tag || github.event.inputs.dist-tag || 'next' }}"
81+
if [[ "$DIST_TAG" == "next" ]]; then
82+
yarn publish:next
83+
elif [[ "$DIST_TAG" == "latest" ]]; then
84+
yarn publish:latest
85+
else
86+
echo "Unknown dist-tag: $DIST_TAG"
87+
exit 1
88+
fi
89+
env:
90+
NPM_CONFIG_PROVENANCE: 'true'

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"lint:ci": "yarn lint --output-file eslint_report.json --format json",
2828
"lint:fix": " yarn lint --fix",
2929
"prepare": "lerna run prepare && yarn build",
30+
"publish:latest": "lerna publish from-package --no-git-reset -y",
3031
"publish:next": "lerna publish preminor --exact --canary --preid next --dist-tag next --no-git-tag-version --no-push --ignore-scripts --yes",
3132
"repo": "yarn -s example repo",
3233
"test": "cd examples/workflow-test && yarn test",
@@ -43,7 +44,7 @@
4344
"@types/node": "20.x",
4445
"concurrently": "^8.2.2",
4546
"eslint-import-resolver-typescript": "^3.5.3",
46-
"lerna": "^7.4.1",
47+
"lerna": "^9.0.0",
4748
"mocha-ctrf-json-reporter": "0.0.9",
4849
"tsc-alias": "1.8.10",
4950
"typescript": "^5.9.2"

0 commit comments

Comments
 (0)