Skip to content

Commit 8a89e03

Browse files
authored
Releng: add publish workflow (#1623)
- Add publish workflow for releases - Remove CLI publish command. With recent changes to NPM and publishing locally without 2FA is no longer really feasible. So the command becomes obsolete
1 parent 1fe323c commit 8a89e03

File tree

4 files changed

+174
-154
lines changed

4 files changed

+174
-154
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_repo:
7+
description: 'GLSP repository to publish'
8+
required: true
9+
type: choice
10+
options:
11+
- glsp
12+
- glsp-client
13+
- glsp-theia-integration
14+
- glsp-server
15+
- glsp-server-node
16+
- glsp-eclipse-integration
17+
- glsp-vscode-integration
18+
- glsp-playwright
19+
branch:
20+
description: 'Branch to use for the release repo (default: default branch)'
21+
required: false
22+
type: string
23+
draft:
24+
description: 'Create draft GitHub release'
25+
required: false
26+
type: boolean
27+
default: false
28+
workflow_call:
29+
inputs:
30+
release_repo:
31+
description: 'GLSP repository to publish'
32+
required: true
33+
type: string
34+
branch:
35+
description: 'Branch to use for the release repo (default: default branch)'
36+
required: false
37+
type: string
38+
draft:
39+
description: 'Create draft GitHub release'
40+
required: false
41+
type: boolean
42+
default: false
43+
44+
jobs:
45+
publish:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout release repo (${{ inputs.release_repo || github.event.inputs.release_repo }})
49+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
50+
with:
51+
repository: eclipse-glsp/${{ inputs.release_repo || github.event.inputs.release_repo }}
52+
path: release-repo
53+
ref: ${{ inputs.branch || github.event.inputs.branch }}
54+
fetch-depth: 0
55+
56+
- name: Configure Git
57+
run: |
58+
git config --global user.name "github-actions[bot]"
59+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
60+
61+
- name: Extract and validate version
62+
id: version
63+
working-directory: ./release-repo
64+
run: |
65+
# Extract version from package.json or pom.xml
66+
if [ -f package.json ]; then
67+
VERSION=$(jq -r '.version' package.json)
68+
elif [ -f pom.xml ]; then
69+
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
70+
else
71+
echo "::error::No package.json or pom.xml found"
72+
exit 1
73+
fi
74+
75+
echo "Detected version: $VERSION"
76+
77+
# Validate: no pre-release versions (no '-' in version)
78+
if [[ "$VERSION" == *-* ]]; then
79+
echo "::error::Cannot publish pre-release version: $VERSION"
80+
exit 1
81+
fi
82+
83+
# Validate: last commit message must contain the version tag
84+
LAST_COMMIT=$(git log -1 --pretty=%s)
85+
if [[ "$LAST_COMMIT" != *"v$VERSION"* ]]; then
86+
echo "::error::Last commit message does not contain v$VERSION: $LAST_COMMIT"
87+
exit 1
88+
fi
89+
90+
# Validate: CHANGELOG.md must have an entry for this version
91+
if ! grep -q "^## \[v$VERSION" CHANGELOG.md; then
92+
echo "::error::CHANGELOG.md has no entry for v$VERSION"
93+
exit 1
94+
fi
95+
96+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
97+
98+
- name: Extract changelog section
99+
id: changelog
100+
working-directory: ./release-repo
101+
run: |
102+
VERSION="${{ steps.version.outputs.version }}"
103+
REPO="${{ inputs.release_repo || github.event.inputs.release_repo }}"
104+
105+
# Extract section: skip the header line, grab until next ## [v heading
106+
CONTENT=$(awk -v ver="$VERSION" '
107+
/^## \[v/ {
108+
if (found) exit
109+
if (index($0, "## [v" ver) == 1) { found=1; next }
110+
}
111+
found { print }
112+
' CHANGELOG.md)
113+
114+
# Remove leading blank lines
115+
CONTENT=$(echo "$CONTENT" | sed '/./,$!d')
116+
117+
# Demote ### headings to ##
118+
CONTENT=$(echo "$CONTENT" | sed 's/^### /## /g')
119+
120+
# Append Full Changelog link if a previous release tag exists
121+
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^v${VERSION}$" | head -1)
122+
if [ -n "$PREV_TAG" ]; then
123+
CONTENT="$CONTENT
124+
125+
**Full Changelog**: https://github.com/eclipse-glsp/$REPO/compare/$PREV_TAG...v$VERSION"
126+
fi
127+
128+
# Write to file for gh release --notes-file
129+
echo "$CONTENT" > "$RUNNER_TEMP/changelog_section.md"
130+
131+
- name: Create and push git tag
132+
working-directory: ./release-repo
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
run: |
136+
VERSION="${{ steps.version.outputs.version }}"
137+
git tag -a "v$VERSION" -m "Release v$VERSION"
138+
git push origin tag "v$VERSION"
139+
140+
- name: Create GitHub release
141+
working-directory: ./release-repo
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
run: |
145+
VERSION="${{ steps.version.outputs.version }}"
146+
REPO="${{ inputs.release_repo || github.event.inputs.release_repo }}"
147+
DRAFT_FLAG=""
148+
if [[ "${{ inputs.draft || github.event.inputs.draft }}" == "true" ]]; then
149+
DRAFT_FLAG="--draft"
150+
fi
151+
152+
gh release create "v$VERSION" \
153+
--title "Release v$VERSION" \
154+
--notes-file "$RUNNER_TEMP/changelog_section.md" \
155+
--repo "eclipse-glsp/$REPO" \
156+
$DRAFT_FLAG
157+
158+
- name: Trigger npm trusted publishing
159+
if: >-
160+
inputs.release_repo != 'glsp-server' &&
161+
inputs.release_repo != 'glsp-eclipse-integration' &&
162+
github.event.inputs.release_repo != 'glsp-server' &&
163+
github.event.inputs.release_repo != 'glsp-eclipse-integration'
164+
env:
165+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166+
run: |
167+
VERSION="${{ steps.version.outputs.version }}"
168+
REPO="${{ inputs.release_repo || github.event.inputs.release_repo }}"
169+
170+
gh workflow run publish.yml \
171+
--repo "eclipse-glsp/$REPO" \
172+
-f "ref=v$VERSION" \
173+
-f "dist-tag=latest"

dev-packages/cli/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ Commands:
141141
version [options] <versionType> [customVersion] Set the version of all packages in a GLSP repository
142142
prepare [options] <versionType> [customVersion] Prepare a new release for a GLSP component (version bump, changelog, PR
143143
creation ...)
144-
publish [options] Publish a new release for a GLSP component (npm, maven, github ...)
145144
help [command] display help for command
146145
```
147146

@@ -199,31 +198,6 @@ Options:
199198
-h, --help display help for command
200199
```
201200

202-
### publish
203-
204-
Helper command for publishing a new GLSP release.
205-
This command should be used on the main branch of GLSP repo after a (previously prepared) Release PR has been merged.
206-
Creates & publishes an new tag and Github release.
207-
In addition, for all non-Java repositories the release version will be published to npm.
208-
209-
The glsp repository type ("glsp-client", "glsp-server-node" etc.) is auto detected from the given repository path.
210-
If the command is invoked in a non-GLSP repository it will fail.
211-
212-
```console
213-
$ glsp releng publish -h\
214-
Usage: glsp releng publish [options]
215-
216-
Publish a new release for a GLSP component (npm, maven, github ...)
217-
218-
Options:
219-
-v, --verbose Enable verbose (debug) log output (default: false)
220-
-r, --repoDir <repoDir> Path to the component repository (default:
221-
"<cwd>")
222-
--no-npm Skip npm publishing
223-
-d, --draft Create a draft GitHub release (default: false)
224-
-h, --help display help for command
225-
```
226-
227201
## More information
228202

229203
For more information, please visit the [Eclipse GLSP Umbrella repository](https://github.com/eclipse-glsp/glsp) and the [Eclipse GLSP Website](https://www.eclipse.org/glsp/).

dev-packages/cli/src/commands/releng/publish.ts

Lines changed: 0 additions & 125 deletions
This file was deleted.

dev-packages/cli/src/commands/releng/releng.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616

1717
import { baseCommand } from '../../util';
1818
import { PrepareReleaseCommand } from './prepare';
19-
import { PublishCommand } from './publish';
2019
import { VersionCommand } from './version';
2120

2221
export const RelengCommand = baseCommand()
2322
.name('releng')
2423
.description('Commands for GLSP release engineering (Linux only, intended for CI/Maintainer use).')
2524
.addCommand(VersionCommand)
26-
.addCommand(PrepareReleaseCommand)
27-
.addCommand(PublishCommand);
25+
.addCommand(PrepareReleaseCommand);

0 commit comments

Comments
 (0)