-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
7,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build and Upload Artifact | ||
runs-on: ubuntu-latest | ||
outputs: | ||
artifact_name: ${{ steps.rename_artifact.outputs.artifact_name }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run build | ||
run: npm run package | ||
|
||
- name: Rename artifact | ||
id: rename_artifact | ||
run: | | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
tagName=${GITHUB_REF#refs/tags/} | ||
echo "Renaming artifact to extension-$tagName.zip" | ||
mv extension.fplx extension-$tagName.zip | ||
echo "artifact_name=extension-$tagName" >> $GITHUB_OUTPUT | ||
echo "artifact_path=extension-$tagName.zip" >> $GITHUB_OUTPUT | ||
else | ||
commitHash=$(git rev-parse --short "$GITHUB_SHA") | ||
echo "Renaming artifact to extension-$commitHash.zip" | ||
mv extension.fplx extension-$commitHash.zip | ||
echo "artifact_name=extension-$commitHash" >> $GITHUB_OUTPUT | ||
echo "artifact_path=extension-$commitHash.zip" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Upload release artifact | ||
if: ${{ !env.ACT }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.rename_artifact.outputs.artifact_name }} | ||
path: ${{ steps.rename_artifact.outputs.artifact_path }} | ||
|
||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v4 | ||
if: ${{ !env.ACT }} | ||
with: | ||
name: ${{ needs.build.outputs.artifact_name }} | ||
|
||
- name: Extract changelog entry | ||
id: changelog | ||
run: | | ||
tagName=${GITHUB_REF#refs/tags/} | ||
tagName=${tagName#v} | ||
awk "/## \\[${tagName}\\]/ {flag=1; next} /^## \\[/ {flag=0} flag {print}" CHANGELOG.md > extracted_changelog.md | ||
echo "Extracted changelog:" | ||
cat extracted_changelog.md | ||
echo "tagName=${tagName}" >> $GITHUB_OUTPUT | ||
- name: Release | ||
if: ${{ !env.ACT }} | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
name: "Release ${{ steps.changelog.outputs.tagName }}" | ||
tag_name: "v${{ steps.changelog.outputs.tagName }}" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body_path: extracted_changelog.md | ||
files: extension-*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/dist | ||
/node_modules | ||
/package | ||
/*.zip | ||
extension.fplx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.0.0] - 2024-12-11 | ||
|
||
### Added | ||
- Inital release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { series } = require('gulp'); | ||
const fs = require('fs'); | ||
const gulp = require('gulp'); | ||
const zip = require('gulp-zip'); | ||
const webpack = require('webpack'); | ||
const merge = require('merge-stream'); | ||
const webpackConfig = require('./webpack.config.js') | ||
|
||
const filesToCopy = [ | ||
'package.json', | ||
'icon.png', | ||
'LICENSE.md', | ||
'README.md' | ||
]; | ||
|
||
function clean(cb) { | ||
fs.rmdir('./package', { recursive: true }, (err) => { | ||
if (err) { console.log('Clean', err) } | ||
cb(); | ||
}); | ||
} | ||
|
||
function build(cb) { | ||
webpack({...webpackConfig, mode: 'production' }, (err, stats) => { | ||
if (err) { console.log('Webpack', err) } | ||
console.log(stats.toString({ /* stats options */ })) | ||
cb(); | ||
}); | ||
} | ||
|
||
function stage() { | ||
const streams = filesToCopy.map(file => { | ||
if (fs.existsSync(file)) { | ||
return gulp.src(file).pipe(gulp.dest('package/hello-world')); | ||
} | ||
}).filter(s => s != undefined); | ||
return merge([ | ||
...streams, | ||
gulp.src('dist/**/*').pipe(gulp.dest('package/hello-world/dist')), | ||
gulp.src('static/**/*').pipe(gulp.dest('package/hello-world/static')), | ||
]); | ||
} | ||
|
||
function package() { | ||
return gulp.src('package/**/*').pipe(zip('extension.fplx')).pipe(gulp.dest('.')); | ||
} | ||
|
||
exports.clean = clean; | ||
exports.build = build; | ||
exports.stage = stage; | ||
exports.package = package; | ||
exports.default = series(clean, build, stage, package); |
Oops, something went wrong.