Skip to content

Commit bc9413b

Browse files
committed
ci: fix workflows
1 parent 1c835de commit bc9413b

File tree

2 files changed

+129
-129
lines changed

2 files changed

+129
-129
lines changed

.github/workflows/build.yml

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
1-
name: Build plugin
2-
3-
permissions:
4-
contents: write
5-
6-
on:
7-
release:
8-
types: [published]
9-
workflow_dispatch: {}
10-
11-
jobs:
12-
build:
13-
name: Build JS bundles
14-
runs-on: ubuntu-latest
15-
16-
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
20-
- name: Setup Node.js
21-
uses: actions/setup-node@v4
22-
with:
23-
node-version: 18
24-
25-
- name: Install dependencies
26-
run: |
27-
npm ci || npm install
28-
29-
- name: Create dist directory
30-
run: mkdir -p dist
31-
32-
- name: Build unminified bundle with esbuild
33-
run: |
34-
npx esbuild src/index.js \
35-
--bundle \
36-
--format=iife \
37-
--global-name=YasguiGraphPlugin \
38-
--define:process.env.NODE_ENV=\"production\" \
39-
--loader:.png=dataurl \
40-
--loader:.svg=dataurl \
41-
--loader:.jpg=dataurl \
42-
--loader:.gif=dataurl \
43-
--outfile=dist/yasgui-graph-plugin.js
44-
45-
- name: Build minified bundle with esbuild
46-
run: |
47-
npx esbuild src/index.js \
48-
--bundle \
49-
--minify \
50-
--format=iife \
51-
--global-name=YasguiGraphPlugin \
52-
--define:process.env.NODE_ENV=\"production\" \
53-
--loader:.png=dataurl \
54-
--loader:.svg=dataurl \
55-
--loader:.jpg=dataurl \
56-
--loader:.gif=dataurl \
57-
--outfile=dist/yasgui-graph-plugin.min.js
58-
59-
- name: Create minified CSS (if available)
60-
run: |
61-
# prefer a root style.css, then demo/style.css, otherwise create a minimal placeholder
62-
if [ -f style.css ]; then
63-
cat style.css > dist/yasgui-graph-plugin.min.css
64-
elif [ -f demo/style.css ]; then
65-
cat demo/style.css > dist/yasgui-graph-plugin.min.css
66-
else
67-
echo '/* yasgui-graph-plugin: no CSS provided */' > dist/yasgui-graph-plugin.min.css
68-
fi
69-
70-
- name: Upload minified JS to GitHub Release
71-
if: github.event_name == 'release'
72-
uses: softprops/action-gh-release@v2
73-
with:
74-
files: |
75-
dist/yasgui-graph-plugin.min.js
76-
dist/yasgui-graph-plugin.min.css
1+
name: Build plugin
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
release:
8+
types: [published]
9+
workflow_dispatch: {}
10+
11+
jobs:
12+
build:
13+
name: Build JS bundles
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
25+
- name: Install dependencies
26+
run: |
27+
npm ci || npm install
28+
29+
- name: Create dist directory
30+
run: mkdir -p dist
31+
32+
- name: Build unminified bundle with esbuild
33+
run: |
34+
npx esbuild src/index.ts \
35+
--bundle \
36+
--format=iife \
37+
--global-name=YasguiGraphPlugin \
38+
--define:process.env.NODE_ENV=\"production\" \
39+
--loader:.png=dataurl \
40+
--loader:.svg=dataurl \
41+
--loader:.jpg=dataurl \
42+
--loader:.gif=dataurl \
43+
--outfile=dist/yasgui-graph-plugin.js
44+
45+
- name: Build minified bundle with esbuild
46+
run: |
47+
npx esbuild src/index.ts \
48+
--bundle \
49+
--minify \
50+
--format=iife \
51+
--global-name=YasguiGraphPlugin \
52+
--define:process.env.NODE_ENV=\"production\" \
53+
--loader:.png=dataurl \
54+
--loader:.svg=dataurl \
55+
--loader:.jpg=dataurl \
56+
--loader:.gif=dataurl \
57+
--outfile=dist/yasgui-graph-plugin.min.js
58+
59+
- name: Create minified CSS (if available)
60+
run: |
61+
# prefer a root style.css, then demo/style.css, otherwise create a minimal placeholder
62+
if [ -f style.css ]; then
63+
cat style.css > dist/yasgui-graph-plugin.min.css
64+
elif [ -f demo/style.css ]; then
65+
cat demo/style.css > dist/yasgui-graph-plugin.min.css
66+
else
67+
echo '/* yasgui-graph-plugin: no CSS provided */' > dist/yasgui-graph-plugin.min.css
68+
fi
69+
70+
- name: Upload minified JS to GitHub Release
71+
if: github.event_name == 'release'
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
files: |
75+
dist/yasgui-graph-plugin.min.js
76+
dist/yasgui-graph-plugin.min.css

.github/workflows/publish.yml

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
name: Publish to npm
2-
3-
on:
4-
release:
5-
types: [created]
6-
7-
permissions:
8-
contents: read
9-
id-token: write
10-
11-
jobs:
12-
publish:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17-
18-
- name: Setup Node.js
19-
uses: actions/setup-node@v4
20-
with:
21-
node-version: '20'
22-
registry-url: 'https://registry.npmjs.org'
23-
24-
# Ensure npm 11.5.1 or later for trusted publishing
25-
- run: npm install -g npm@latest
26-
27-
- name: Install dependencies
28-
run: npm ci
29-
30-
- name: Build plugin
31-
run: npm run build
32-
33-
- name: Update package version from release tag
34-
run: |
35-
TAG_VERSION=${GITHUB_REF#refs/tags/}
36-
TAG_VERSION=${TAG_VERSION#v}
37-
npm version $TAG_VERSION --no-git-tag-version --allow-same-version
38-
39-
- name: Check if version already published
40-
id: check
41-
run: |
42-
PACKAGE_NAME=$(node -p "require('./package.json').name")
43-
VERSION=$(node -p "require('./package.json').version")
44-
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
45-
echo "Version $VERSION already published, skipping"
46-
echo "skip=true" >> $GITHUB_OUTPUT
47-
else
48-
echo "Version $VERSION not published yet"
49-
echo "skip=false" >> $GITHUB_OUTPUT
50-
fi
51-
52-
- name: Publish to npm
53-
if: steps.check.outputs.skip != 'true'
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
# Ensure npm 11.5.1 or later for trusted publishing
25+
- run: npm install -g npm@latest
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build plugin
31+
run: npm run build
32+
33+
- name: Update package version from release tag
34+
run: |
35+
TAG_VERSION=${GITHUB_REF#refs/tags/}
36+
TAG_VERSION=${TAG_VERSION#v}
37+
npm version $TAG_VERSION --no-git-tag-version --allow-same-version
38+
39+
- name: Check if version already published
40+
id: check
41+
run: |
42+
PACKAGE_NAME=$(node -p "require('./package.json').name")
43+
VERSION=$(node -p "require('./package.json').version")
44+
if npm view "$PACKAGE_NAME@$VERSION" version 2>/dev/null; then
45+
echo "Version $VERSION already published, skipping"
46+
echo "skip=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "Version $VERSION not published yet"
49+
echo "skip=false" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Publish to npm
53+
if: steps.check.outputs.skip != 'true'
5454
run: npm publish --provenance --access public

0 commit comments

Comments
 (0)