From d8ee6eadfefb4d5dfdaf6b134020a41497a658fc Mon Sep 17 00:00:00 2001 From: ILOVEPIE Date: Sun, 11 Feb 2024 17:01:46 -0800 Subject: [PATCH] Created a github action to auto-build the library. Also fixed a test error and two warnings. --- .github/release-drafter.yml | 2 +- .github/workflows/build.yml | 98 +++++++++++++++++++++++++++++ .github/workflows/release-draft.yml | 15 ----- package.json | 2 +- src/__tests__/parser.test.js | 2 +- src/font-server.js | 8 +-- 6 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/release-draft.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index dfac5c0..6eee352 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,5 +1,5 @@ name-template: "v$RESOLVED_VERSION" -tag-template: "v$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" categories: - title: "🚀 Features" labels: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f58bb58 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,98 @@ +name: Build + +on: + push: + branches: + - master + - stable + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + + - name: Set up Node.js + uses: actions/setup-node@v4.0.2 + with: + node-version: '21' + + - name: Set up Java + uses: actions/setup-java@v4.0.0 + with: + java-version: '21' + distribution: 'temurin' + + - name: Get next version + uses: reecetech/version-increment@2023.10.2 + id: version + with: + scheme: semver + release_branch: stable + increment: patch + + - name: Tag Commit + if: github.ref == 'refs/heads/stable' + uses: CrabMatrix/github-tagger@v1.0.16 + with: + tag: ${{ steps.version.outputs.version }} + repo-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Build package + run: | + echo "Building package" + make pkg + + - name: Update package version + run: | + echo "Updating package version to ${{ steps.version.outputs.version }}" + sed -i "s/\"version\": \".*\"/\"version\": \"${{ steps.version.outputs.version }}\"/" temp_files/sabre/package.json + + - name: Publish package + run: | + echo "Publishing package" + pushd temp_files/sabre && npm config set _authToken=$NODE_AUTH_TOKEN && npm publish && popd + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Create release + if: github.ref == 'refs/heads/stable' + id: create_release + uses: release-drafter/release-drafter@v6.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + config-file: .github/release-drafter.yml + tag: ${{ steps.version.outputs.version }} + name: ${{ steps.version.outputs.version }} + version: ${{ steps.version.outputs.version }} + + - name: Zip Release + if: github.ref == 'refs/heads/stable' + run: zip -r -9 SABRE,js-${{ steps.version.outputs.version }}.zip ./bin ./debugbin ./LICENSE.md + + - name: Upload Release + if: github.ref == 'refs/heads/stable' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./SABRE,js-${{ steps.version.outputs.version }}.zip + asset_name: SABRE,js-${{ steps.version.outputs.version }}.zip + asset_content_type: application/zip + + - name: Publish Release + if: github.ref == 'refs/heads/stable' + uses: eregon/publish-release@v1.0.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_id: ${{ steps.create_release.outputs.id }} + + + + + diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml deleted file mode 100644 index b698a07..0000000 --- a/.github/workflows/release-draft.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Release Drafter -on: - push: - branches: - - master - pull_request: - types: [opened, reopened, synchronize] - -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - - uses: release-drafter/release-drafter@v5.15.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 0088f90..fbd3ed7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sabre-js/sabre", - "version": "0.2.0-git", + "version": "git", "description": "A gpu accelerated ecmascript renderer for Advanced Substation Alpha (ASS) subtitles. Renders .ass and .ssa files over video in the browser.", "main": "dist/sabre.min.js", "types": "types/sabre.d.ts", diff --git a/src/__tests__/parser.test.js b/src/__tests__/parser.test.js index facb0aa..4253164 100644 --- a/src/__tests__/parser.test.js +++ b/src/__tests__/parser.test.js @@ -1,6 +1,6 @@ global = globalThis; -require('../global-constants.js') require('../util.js') +require('../global-constants.js') require('../color.js'); require('../style.js'); require('../style-override.js'); diff --git a/src/font-server.js b/src/font-server.js index d63a1ee..1a315d6 100644 --- a/src/font-server.js +++ b/src/font-server.js @@ -13,18 +13,18 @@ * @private * @enum {number} */ -const platforms = Object.freeze({ +const platforms = { UNICODE: 0, APPLE: 1, MICROSOFT: 3 -}); +}; /** * An enum of name types. * @private * @enum {number} */ -const nameTypes = Object.freeze({ +const nameTypes = { COPYRIGHT: 0, FONT_FAMILY: 1, FONT_SUBFAMILY: 2, @@ -33,7 +33,7 @@ const nameTypes = Object.freeze({ VERSION_STRING: 5, PS_NAME: 6, TRADEMARK: 7 -}); +}; const font_server_prototype = Object.create(Object, { _fonts: {