Skip to content

Commit d33a010

Browse files
committed
add rollup based packaging system
1 parent 72325bc commit d33a010

6 files changed

Lines changed: 617 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Build
3+
4+
on:
5+
push:
6+
branches: [master]
7+
paths:
8+
- unite@hardpixel.eu/**
9+
- package.json
10+
- yarn.lock
11+
- rollup.config.js
12+
pull_request:
13+
branches: [master]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
node: [16.0, 18.0]
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
29+
- uses: actions/setup-node@v3
30+
with:
31+
node-version: ${{ matrix.node }}
32+
33+
- name: Enable corepack
34+
run: corepack enable
35+
36+
- name: Install dependencies
37+
run: yarn install
38+
39+
- name: Run build
40+
run: yarn build

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Release
3+
run-name: Release v${{ github.event.inputs.version }}
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: Version
10+
required: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v3
21+
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
26+
- name: Enable corepack
27+
run: corepack enable
28+
29+
- name: Install dependencies
30+
run: yarn install
31+
32+
- name: Run package
33+
run: yarn package
34+
35+
- uses: svenstaro/upload-release-action@v2
36+
if: ${{ !env.ACT }}
37+
with:
38+
overwrite: true
39+
file: build/unite-v${{ github.event.inputs.version }}.zip
40+
tag: v${{ github.event.inputs.version }}
41+
body: Version ${{ github.event.inputs.version }}

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
.DS_Store
2+
node_modules
3+
dist
4+
build
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
15+
# Editor directories and files
16+
.idea
17+
.vscode
18+
*.suo
19+
*.ntvs*
20+
*.njsproj
21+
*.sln
22+
*.sw*
23+
24+
# build files
125
*.ui~
226
*.ui#
327
*.mo

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "unite",
3+
"version": "84",
4+
"description": "Unite is an extension that makes GNOME Shell look like Ubuntu Unity Shell",
5+
"repository": "https://github.com/hardpixel/unite-shell",
6+
"author": "Jonian Guveli",
7+
"license": "GPL",
8+
"private": true,
9+
"scripts": {
10+
"build": "rollup -c",
11+
"package": "package=1 rollup -c"
12+
},
13+
"devDependencies": {
14+
"rollup": "^2.79.2",
15+
"rollup-plugin-copy": "latest",
16+
"rollup-plugin-delete": "latest",
17+
"rollup-plugin-zipdir": "latest"
18+
}
19+
}

rollup.config.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import pkg from './package.json'
2+
3+
import copy from 'rollup-plugin-copy'
4+
import del from 'rollup-plugin-delete'
5+
import zip from 'rollup-plugin-zipdir'
6+
7+
import fs from 'fs'
8+
import chp from 'child_process'
9+
10+
function builder({ name }) {
11+
return {
12+
name: 'build-manager',
13+
load: () => '',
14+
resolveId: () => name,
15+
buildStart() {
16+
this.emitFile({
17+
id: name,
18+
fileName: 'empty.js',
19+
type: 'chunk'
20+
})
21+
},
22+
generateBundle({ dir }) {
23+
if (dir && fs.existsSync(dir)) {
24+
fs.rmSync(dir, { recursive: true })
25+
}
26+
},
27+
writeBundle({ dir }) {
28+
if (dir && fs.existsSync(dir)) {
29+
chp.exec('glib-compile-schemas schemas', { cwd: dir }, (error, stdout, stderr) => {
30+
if (error || stderr) {
31+
console.error(error || stderr)
32+
}
33+
})
34+
}
35+
}
36+
}
37+
}
38+
39+
export default {
40+
output: {
41+
dir: 'dist',
42+
format: 'esm'
43+
},
44+
plugins: [
45+
builder({
46+
name: pkg.name
47+
}),
48+
del({
49+
hook: 'writeBundle',
50+
targets: [
51+
'dist/empty.js',
52+
'build/*.zip'
53+
]
54+
}),
55+
copy({
56+
hook: 'generateBundle',
57+
targets: [
58+
{ src: 'unite@hardpixel.eu/*', dest: 'dist' }
59+
]
60+
}),
61+
process.env.package && zip({
62+
name: `${pkg.name}-v${pkg.version}.zip`,
63+
outputDir: 'build'
64+
})
65+
]
66+
}

0 commit comments

Comments
 (0)