Skip to content

Commit

Permalink
Create workflow build.yml
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mtlljm authored Oct 31, 2023
1 parent f00160e commit 711bc9a
Show file tree
Hide file tree
Showing 5 changed files with 10,354 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const config = async (env): Promise<Configuration> => ({
loader: 'swc-loader',
options: {
jsc: {
baseUrl: './src',
baseUrl: path.resolve(__dirname, 'src'),
target: 'es2015',
loose: false,
parser: {
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build

on:
push:
branches: [ "main", "build-test" ]
workflow_dispatch:
inputs:
release:
description: 'Make a release build'
required: false
type: boolean

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up yarn
uses: DerYeger/yarn-setup-action@master
with:
node-version: 16.14.0

- name: Build yarn
run: |
yarn build
pwd
ls -la ./dist
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build go
run: |
go run mage.go
ls -la ./dist
- name: Zip artifacts
run: |
yarn zip
ls -la
- uses: actions/upload-artifact@v3
name: Attatch artifacts to job
with:
name: sasesp-plugin-zip-files
path: ./sasesp-plugin*.zip
retention-days: 7

- name: Bump version and push tag
if: startsWith(github.event.head_commit.message, 'release:')
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create a GitHub release
if: startsWith(github.event.head_commit.message, 'release:')
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: "./sasesp-plugin*.zip"
22 changes: 22 additions & 0 deletions makezip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var zip = require('bestzip');
var packageJson = require('./package.json');

zip({
source: packageJson.name + '/*',
destination: './' + packageJson.name + '-' + packageJson.version + '.zip'
}).then(function() {
console.log('Zip complete.');
}).catch(function(err) {
console.error(err.stack);
process.exit(1);
});

zip({
source: packageJson.name + '-all' + '/*',
destination: './' + packageJson.name + '-' + packageJson.version + '-all' + '.zip'
}).then(function() {
console.log('Zip complete.');
}).catch(function(err) {
console.error(err.stack);
process.exit(1);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "jest --watch --onlyChanged",
"test:ci": "jest --passWithNoTests --maxWorkers 4",
"typecheck": "tsc --noEmit",
"zip": "cp dist sas-esp-grafana-plugin && bestzip sas-esp-grafana-plugin.zip sas-esp-grafana-plugin"
"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"
},
"license": "Apache-2.0",
"devDependencies": {
Expand Down
Loading

0 comments on commit 711bc9a

Please sign in to comment.