Skip to content

Commit 711bc9a

Browse files
authored
Create workflow build.yml
Create a workflow to build and optionally release the plugin. Fix - .config/webpack/webpack.config.ts - as it was failing on relative path Add makezip.js to make the zip bundles based on the package.json version number
1 parent f00160e commit 711bc9a

File tree

5 files changed

+10354
-2
lines changed

5 files changed

+10354
-2
lines changed

.config/webpack/webpack.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const config = async (env): Promise<Configuration> => ({
8686
loader: 'swc-loader',
8787
options: {
8888
jsc: {
89-
baseUrl: './src',
89+
baseUrl: path.resolve(__dirname, 'src'),
9090
target: 'es2015',
9191
loose: false,
9292
parser: {

.github/workflows/build.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ "main", "build-test" ]
6+
workflow_dispatch:
7+
inputs:
8+
release:
9+
description: 'Make a release build'
10+
required: false
11+
type: boolean
12+
13+
jobs:
14+
15+
build:
16+
name: Build
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Set up yarn
20+
uses: DerYeger/yarn-setup-action@master
21+
with:
22+
node-version: 16.14.0
23+
24+
- name: Build yarn
25+
run: |
26+
yarn build
27+
pwd
28+
ls -la ./dist
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v4
32+
with:
33+
go-version: '1.20'
34+
35+
- name: Build go
36+
run: |
37+
go run mage.go
38+
ls -la ./dist
39+
40+
- name: Zip artifacts
41+
run: |
42+
yarn zip
43+
ls -la
44+
45+
- uses: actions/upload-artifact@v3
46+
name: Attatch artifacts to job
47+
with:
48+
name: sasesp-plugin-zip-files
49+
path: ./sasesp-plugin*.zip
50+
retention-days: 7
51+
52+
- name: Bump version and push tag
53+
if: startsWith(github.event.head_commit.message, 'release:')
54+
id: tag_version
55+
uses: mathieudutour/[email protected]
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Create a GitHub release
60+
if: startsWith(github.event.head_commit.message, 'release:')
61+
uses: ncipollo/release-action@v1
62+
with:
63+
tag: ${{ steps.tag_version.outputs.new_tag }}
64+
name: Release ${{ steps.tag_version.outputs.new_tag }}
65+
body: ${{ steps.tag_version.outputs.changelog }}
66+
artifacts: "./sasesp-plugin*.zip"

makezip.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var zip = require('bestzip');
2+
var packageJson = require('./package.json');
3+
4+
zip({
5+
source: packageJson.name + '/*',
6+
destination: './' + packageJson.name + '-' + packageJson.version + '.zip'
7+
}).then(function() {
8+
console.log('Zip complete.');
9+
}).catch(function(err) {
10+
console.error(err.stack);
11+
process.exit(1);
12+
});
13+
14+
zip({
15+
source: packageJson.name + '-all' + '/*',
16+
destination: './' + packageJson.name + '-' + packageJson.version + '-all' + '.zip'
17+
}).then(function() {
18+
console.log('Zip complete.');
19+
}).catch(function(err) {
20+
console.error(err.stack);
21+
process.exit(1);
22+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"test": "jest --watch --onlyChanged",
1616
"test:ci": "jest --passWithNoTests --maxWorkers 4",
1717
"typecheck": "tsc --noEmit",
18-
"zip": "cp dist sas-esp-grafana-plugin && bestzip sas-esp-grafana-plugin.zip sas-esp-grafana-plugin"
18+
"zip": "cp -r dist sasesp-plugin && rm ./sasesp-plugin/*darwin* && rm ./sasesp-plugin/*windows* && rm ./sasesp-plugin/*arm* && cp -r dist sasesp-plugin-all && node makezip.js"
1919
},
2020
"license": "Apache-2.0",
2121
"devDependencies": {

0 commit comments

Comments
 (0)