Skip to content

Commit d1d83b5

Browse files
authored
ci: kickoff publish packages into npmjs workflow (#1997)
1 parent 3e6dff8 commit d1d83b5

File tree

2 files changed

+203
-15
lines changed

2 files changed

+203
-15
lines changed

.github/workflows/publish.yml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
name: 🚀 Publish ExTester
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Version tag to publish (vX.X.X)"
8+
required: true
9+
skipPublish:
10+
description: "Skip publish into NPM registry (npmjs)"
11+
default: false
12+
type: boolean
13+
skipPackageJsonMatch:
14+
description: "Skip tag validation with package.json (testing)"
15+
default: false
16+
type: boolean
17+
draft:
18+
description: "Publish GH release as draft"
19+
default: false
20+
type: boolean
21+
22+
permissions:
23+
contents: write
24+
25+
jobs:
26+
build-and-publish:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: 🔖 Show input tag
31+
run: echo "Publishing version ${{ github.event.inputs.tag }}"
32+
33+
- name: 👷🏻 Checkout Repository
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: ✅ Verify Git tag exists
39+
run: |
40+
git fetch --tags
41+
if ! git rev-parse "refs/tags/${{ github.event.inputs.tag }}" >/dev/null 2>&1; then
42+
echo "❌ Tag '${{ github.event.inputs.tag }}' does not exist!"
43+
exit 1
44+
fi
45+
46+
- name: ✅ Validate and extract tag
47+
run: |
48+
TAG=${{ github.event.inputs.tag }}
49+
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
50+
echo "❌ Invalid tag format: $TAG. Use format like 'v1.2.3'"
51+
exit 1
52+
fi
53+
echo "TAG=$TAG" >> $GITHUB_ENV
54+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
55+
56+
- name: ✅ Ensure tag matches package.json version
57+
if: ${{ github.event.inputs.skipPackageJsonMatch != 'true' }}
58+
working-directory: packages/extester
59+
run: |
60+
PKG_VERSION=$(node -p "require('./package.json').version")
61+
TAG_VERSION=${VERSION}
62+
echo "Package version: $PKG_VERSION"
63+
echo "Input tag version: $TAG_VERSION"
64+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
65+
echo "❌ Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)!"
66+
exit 1
67+
fi
68+
69+
- name: 🔸 Get vscode-extension-tester version
70+
working-directory: packages/extester
71+
run: |
72+
VERSION=$(node -p "require('./package.json').version")
73+
echo "EXTESTER_VERSION=${VERSION}" >> $GITHUB_ENV
74+
75+
- name: 🔸 Get @redhat-developer/page-objects version
76+
working-directory: packages/page-objects
77+
run: |
78+
VERSION=$(node -p "require('./package.json').version")
79+
echo "PAGE_OBJECTS_VERSION=${VERSION}" >> $GITHUB_ENV
80+
81+
- name: 🔸 Get @redhat-developer/locators version
82+
working-directory: packages/locators
83+
run: |
84+
VERSION=$(node -p "require('./package.json').version")
85+
echo "LOCATORS_VERSION=${VERSION}" >> $GITHUB_ENV
86+
87+
- name: ⚙️ Set up Node.js
88+
uses: actions/setup-node@v4
89+
with:
90+
node-version: 20
91+
92+
- name: 📦 Install GitHub CLI
93+
run: sudo apt-get install -y gh
94+
95+
- name: 🔧 Install deps and build
96+
run: |
97+
npm ci
98+
npm run build
99+
100+
- name: 📝 Generate changelog
101+
run: |
102+
PREV_TAG=$(git tag --list "v*" --sort=-creatordate | grep -v "$TAG" | head -n 1)
103+
echo "Comparing changes from $PREV_TAG to $TAG"
104+
105+
if [ -z "$PREV_TAG" ]; then
106+
LOG=$(git log "$TAG" --reverse --pretty='format:%s by **%aN** in %H' -- . | grep -vE "(runner)")
107+
[ -z "$LOG" ] && LOG=$(git log --reverse --pretty='format:%s by **%aN** in %H' -- . | grep -vE "(runner)")
108+
else
109+
LOG=$(git log "$PREV_TAG..$TAG" --pretty='format:%s by **%aN** in %H' -- . | grep -vE "(runner)")
110+
fi
111+
112+
if [ -z "$LOG" ]; then
113+
LOG="Initial release (first tag)"
114+
fi
115+
116+
# Helper to format sections
117+
format_section() {
118+
local pattern="$1"
119+
local title="$2"
120+
local content=$(echo "$LOG" | grep -iE "$pattern" || true)
121+
if [[ -n "$content" ]]; then
122+
echo "### $title"
123+
echo "$content"
124+
echo
125+
fi
126+
}
127+
128+
format_other_section() {
129+
local title="🧼 Other Changes"
130+
local content=$(echo "$LOG" | grep -vE "^(feat|feature|fix|test|chore|refactor|internal|ci|docs|deps|dependencies|build)" || true)
131+
if [[ -n "$content" ]]; then
132+
echo "### $title"
133+
echo "$content"
134+
echo
135+
fi
136+
}
137+
138+
{
139+
echo "## What's Changed"
140+
format_section '^break|^breaking' "⚠️ Breaking"
141+
format_section '^feat|^feature' "🚀 Features"
142+
format_section '^fix' "🚫 Bugs"
143+
format_section '^test' "🔎 Tests"
144+
format_section '^chore|^refactor|^internal|^ci|^docs' "🔧 Maintenance"
145+
format_section '^deps|^dependencies|^build' "📦 Dependencies"
146+
format_other_section
147+
} > CHANGELOG.md
148+
149+
echo "Generated CHANGELOG.md"
150+
cat CHANGELOG.md
151+
152+
- name: 🚀 Publish to NPM registry (npmjs)
153+
if: ${{ github.event.inputs.skipPublish != 'true' }}
154+
run: npm run publish -- --yes
155+
env:
156+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
157+
158+
- name: 📣 Add summary
159+
if: ${{ github.event.inputs.skipPublish != 'true' }}
160+
run: |
161+
echo "#### ✅ Published \`vscode-extension-tester-${EXTESTER_VERSION}\`" >> $GITHUB_STEP_SUMMARY
162+
echo "#### ✅ Published \`@redhat-developer/page-objects-${PAGE_OBJECTS_VERSION}\`" >> $GITHUB_STEP_SUMMARY
163+
echo "#### ✅ Published \`@redhat-developer/locators-${LOCATORS_VERSION}\`" >> $GITHUB_STEP_SUMMARY
164+
165+
- name: 🚀 Publish GitHub Release
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
run: |
169+
if [ "${{ github.event.inputs.draft }}" == "true" ]; then
170+
echo "Publishing release as draft..."
171+
gh release create "$TAG" --title "v${VERSION}" --notes-file CHANGELOG.md --draft
172+
else
173+
echo "Publishing release as a regular release..."
174+
gh release create "$TAG" --title "v${VERSION}" --notes-file CHANGELOG.md
175+
fi

.github/workflows/runner-publish.yaml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
description: "Skip tag validation with package.json (testing)"
1515
default: false
1616
type: boolean
17+
draft:
18+
description: "Publish GH release as draft"
19+
default: false
20+
type: boolean
1721

1822
permissions:
1923
contents: write
@@ -90,18 +94,18 @@ jobs:
9094
echo "Comparing changes from $PREV_TAG to $TAG"
9195
9296
if [ -z "$PREV_TAG" ]; then
93-
LOG=$(git log "$TAG" --reverse --oneline -- .)
94-
[ -z "$LOG" ] && LOG=$(git log --reverse --oneline -- .)
97+
LOG=$(git log "$TAG" --reverse ---pretty='format:%s by **%aN** in %H' -- .)
98+
[ -z "$LOG" ] && LOG=$(git log --reverse --pretty='format:%s by **%aN** in %H' -- .)
9599
else
96-
LOG=$(git log "$PREV_TAG..$TAG" --oneline -- .)
100+
LOG=$(git log "$PREV_TAG..$TAG" --pretty='format:%s by **%aN** in %H' -- .)
97101
fi
98102
99103
if [ -z "$LOG" ]; then
100104
LOG="Initial release (first tag)"
101105
fi
102106
103107
format_section() {
104-
local pattern="($1)\(runner\)"
108+
local pattern="$1"
105109
local title="$2"
106110
local content=$(echo "$LOG" | grep -iE "$pattern" || true)
107111
if [[ -n "$content" ]]; then
@@ -113,7 +117,7 @@ jobs:
113117
114118
format_other_section() {
115119
local title="🧼 Other Changes"
116-
local content=$(echo "$LOG" | grep -vE "(feat|feature|fix|test|chore|refactor|internal|ci|docs|deps|dependencies)\(runner\)" || true)
120+
local content=$(echo "$LOG" | grep -vE "^(feat|feature|fix|test|chore|refactor|internal|ci|docs|deps|dependencies|build)" || true)
117121
if [[ -n "$content" ]]; then
118122
echo "### $title"
119123
echo "$content"
@@ -123,12 +127,12 @@ jobs:
123127
124128
{
125129
echo "## What's Changed"
126-
format_section 'break|breaking' "⚠️ Breaking"
127-
format_section 'feat|feature' "🚀 Features"
128-
format_section 'fix' "🚫 Bugs"
129-
format_section 'test' "🔎 Tests"
130-
format_section 'chore|refactor|internal|ci|docs' "🔧 Maintenance"
131-
format_section 'deps|dependencies' "📦 Dependencies"
130+
format_section '^break|^breaking' "⚠️ Breaking"
131+
format_section '^feat|^feature' "🚀 Features"
132+
format_section '^fix' "🚫 Bugs"
133+
format_section '^test' "🔎 Tests"
134+
format_section '^chore|^refactor|^internal|^ci|^docs' "🔧 Maintenance"
135+
format_section '^deps|^dependencies|^build' "📦 Dependencies"
132136
format_other_section
133137
} > CHANGELOG.md
134138
@@ -165,7 +169,16 @@ jobs:
165169
env:
166170
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167171
run: |
168-
gh release create "$TAG" \
169-
--title "ExTester Runner - Preview (v${VERSION})" \
170-
--notes-file CHANGELOG.md \
171-
extester-runner-${VERSION}.vsix
172+
if [ "${{ github.event.inputs.draft }}" == "true" ]; then
173+
echo "Publishing release as draft..."
174+
gh release create "$TAG" --draft \
175+
--title "ExTester Runner - Preview (v${VERSION})" \
176+
--notes-file CHANGELOG.md \
177+
extester-runner-${VERSION}.vsix
178+
else
179+
echo "Publishing release as a regular release..."
180+
gh release create "$TAG" \
181+
--title "ExTester Runner - Preview (v${VERSION})" \
182+
--notes-file CHANGELOG.md \
183+
extester-runner-${VERSION}.vsix
184+
fi

0 commit comments

Comments
 (0)