From df2260d318e290f015da305b1cf27a023566e521 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 18:39:48 -0500 Subject: [PATCH 1/8] Updated actions/checkout version. --- .github/workflows/test-ref-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-ref-branch.yml b/.github/workflows/test-ref-branch.yml index ecb5b6d..bb75cd4 100644 --- a/.github/workflows/test-ref-branch.yml +++ b/.github/workflows/test-ref-branch.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout default repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Reference branch id: ref-branch From ba903177e2f84fdb46cc85ca03874ac898a39239 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 18:42:19 -0500 Subject: [PATCH 2/8] Refactored release workflow. --- actions/build-test-publish/action.yml | 102 ++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 actions/build-test-publish/action.yml diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml new file mode 100644 index 0000000..3f3ea95 --- /dev/null +++ b/actions/build-test-publish/action.yml @@ -0,0 +1,102 @@ +name: Build, test, publish +description: Build, optionally test, and optionally publish to NPM + +inputs: + vars: + description: JSON representation of workflow vars object + required: true + +runs: + using: composite + + steps: + - name: Dump vars + shell: bash + run: | + cat << EOF + ${{ toJSON(vars) }} + EOF + + - name: Dump GitHub context + shell: bash + run: | + cat << EOF + ${{ toJSON(github) }} + EOF + + - name: Setup node + uses: actions/setup-node@v6 + with: + node-version: ${{ fromJSON(inputs.vars).NODE_VERSION }} + registry-url: https://registry.npmjs.org/ + + - name: Start terminal session (pre build) + if: fromJSON(inputs.vars).TERMINAL_PRE_BUILD == 'true' + uses: mxschmitt/action-tmate@v3 + + - name: Build + id: build + shell: bash + run: | + # Get the name property. + name=`grep "^ \"name\": " package.json | cut -d "\"" -f 4 -s` + + # Get the version property. + version=`grep "^ \"version\": " package.json | cut -d "\"" -f 4 -s` + + # Get the label on the version property if any, minus pre-release identifier if any. + label=`echo $version | cut -d "-" -f 2 -s | cut -d "." -f 1` + + # Save the properties for future steps. + echo "name=$name" >> $GITHUB_OUTPUT + echo "version=$version" >> $GITHUB_OUTPUT + echo "label=label" >> $GITHUB_OUTPUT + + npm install + + # If version has a label, build in development mode. + if [[ label != "" ]] + then + npm run build:dev + else + npm run build:release + fi + + - name: Start terminal session (post build) + if: fromJSON(inputs.vars).TERMINAL_POST_BUILD == 'true' + uses: mxschmitt/action-tmate@v3 + + - name: Test + shell: bash + run: | + # Run test script if present. + npm run test --if-present + + - name: Publish + shell: bash + run: | + name="${{ steps.build.outputs.name }}" + version="${{ steps.build.outputs.version }}" + label="${{ steps.build.outputs.label }}" + + # If version has a label, use it as the tag. + if [[ $label != "" ]] + then + tag_args="--tag $label" + fi + + if [[ "${{ github.event_name }}" != "release" ]] + then + dry_run_arg="--dry-run" + fi + + # Create .npmignore to exclude hidden directories. + echo /.\*/ > .npmignore + + npm publish --access public $tag_args $dry_run_arg + + # If the latest version has the same label as this version, replace with this version. + if [[ $label != "" && "$label" = `npm view $name version | cut -d "-" -f 2 -s | cut -d "." -f 1` ]] + then + npm dist-tag add $name@$version latest $dry_run_arg + fi From 11091ff8bc950000d7303db1178d781cca0e22b8 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 20:50:08 -0500 Subject: [PATCH 3/8] Removed dumping of vars and github objects. --- actions/build-test-publish/action.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml index 3f3ea95..6de82f0 100644 --- a/actions/build-test-publish/action.yml +++ b/actions/build-test-publish/action.yml @@ -10,20 +10,6 @@ runs: using: composite steps: - - name: Dump vars - shell: bash - run: | - cat << EOF - ${{ toJSON(vars) }} - EOF - - - name: Dump GitHub context - shell: bash - run: | - cat << EOF - ${{ toJSON(github) }} - EOF - - name: Setup node uses: actions/setup-node@v6 with: From 581f4556e78f3921cf1f8ceb8d3b340b59b7e172 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 21:06:34 -0500 Subject: [PATCH 4/8] Fixed handling of label variable. --- actions/build-test-publish/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml index 6de82f0..c2dde91 100644 --- a/actions/build-test-publish/action.yml +++ b/actions/build-test-publish/action.yml @@ -36,12 +36,12 @@ runs: # Save the properties for future steps. echo "name=$name" >> $GITHUB_OUTPUT echo "version=$version" >> $GITHUB_OUTPUT - echo "label=label" >> $GITHUB_OUTPUT + echo "label=$label" >> $GITHUB_OUTPUT npm install # If version has a label, build in development mode. - if [[ label != "" ]] + if [[ "$label" != "" ]] then npm run build:dev else @@ -66,7 +66,7 @@ runs: label="${{ steps.build.outputs.label }}" # If version has a label, use it as the tag. - if [[ $label != "" ]] + if [[ "$label" != "" ]] then tag_args="--tag $label" fi @@ -82,7 +82,7 @@ runs: npm publish --access public $tag_args $dry_run_arg # If the latest version has the same label as this version, replace with this version. - if [[ $label != "" && "$label" = `npm view $name version | cut -d "-" -f 2 -s | cut -d "." -f 1` ]] + if [[ "$label" != "" && "$label" = `npm view $name version | cut -d "-" -f 2 -s | cut -d "." -f 1` ]] then npm dist-tag add $name@$version latest $dry_run_arg fi From 5f626abc8b97c98acccd0082dd7ce1f4acfff1a3 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 22:45:45 -0500 Subject: [PATCH 5/8] Added exchange token to support tag manipulation. --- actions/build-test-publish/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml index c2dde91..7f88288 100644 --- a/actions/build-test-publish/action.yml +++ b/actions/build-test-publish/action.yml @@ -58,6 +58,11 @@ runs: # Run test script if present. npm run test --if-present + - name: Exchange token + uses: electron/npm-trusted-auth-action@v1 + with: + package-name: ${{ steps.build.outputs.name }} + - name: Publish shell: bash run: | From f7de6e55ee7e52b650d29d96ca274e67b4439aff Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 23:07:45 -0500 Subject: [PATCH 6/8] Fixed version of exchange token. --- actions/build-test-publish/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml index 7f88288..8f42323 100644 --- a/actions/build-test-publish/action.yml +++ b/actions/build-test-publish/action.yml @@ -59,7 +59,7 @@ runs: npm run test --if-present - name: Exchange token - uses: electron/npm-trusted-auth-action@v1 + uses: electron/npm-trusted-auth-action@v1.0.0 with: package-name: ${{ steps.build.outputs.name }} From 973efef25230dfadba206e3591009cd02321b2a3 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Sun, 23 Nov 2025 23:17:50 -0500 Subject: [PATCH 7/8] Removed exchange token and disabled dist-tag call. --- actions/build-test-publish/action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/actions/build-test-publish/action.yml b/actions/build-test-publish/action.yml index 8f42323..cb2aa02 100644 --- a/actions/build-test-publish/action.yml +++ b/actions/build-test-publish/action.yml @@ -58,11 +58,6 @@ runs: # Run test script if present. npm run test --if-present - - name: Exchange token - uses: electron/npm-trusted-auth-action@v1.0.0 - with: - package-name: ${{ steps.build.outputs.name }} - - name: Publish shell: bash run: | @@ -89,5 +84,5 @@ runs: # If the latest version has the same label as this version, replace with this version. if [[ "$label" != "" && "$label" = `npm view $name version | cut -d "-" -f 2 -s | cut -d "." -f 1` ]] then - npm dist-tag add $name@$version latest $dry_run_arg + echo "Run: npm dist-tag add $name@$version latest $dry_run_arg" fi From a873988bb73b9ffadaa4006abb45b2bdd08d0b56 Mon Sep 17 00:00:00 2001 From: Kevin Dean Date: Mon, 24 Nov 2025 11:04:15 -0500 Subject: [PATCH 8/8] Added support for checkout path. --- actions/ref-branch/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/actions/ref-branch/action.yml b/actions/ref-branch/action.yml index 9efdbf3..ea4db7d 100644 --- a/actions/ref-branch/action.yml +++ b/actions/ref-branch/action.yml @@ -1,6 +1,12 @@ name: Reference branch description: Parse the GitHub context reference properties to determine the branch on which the workflow is running +inputs: + path: + description: Path to which repository has been checked out + required: false + default: . + outputs: branch: description: Fully formed reference of the branch @@ -16,6 +22,7 @@ runs: - name: Reference branch id: ref-branch shell: bash + working-directory: ${{ inputs.path }} run: | if [[ "${{ github.ref_type }}" = "branch" ]] then