Skip to content

Commit

Permalink
ci: refactor nodejs puslish (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
moomiji authored Dec 22, 2024
1 parent 6f97c37 commit 5f3b1f5
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 88 deletions.
96 changes: 96 additions & 0 deletions .github/actions/publish_nodejs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: publish nodejs package
description: publish nodejs package
inputs:
token:
description: The NPM access token to use when publishing
required: true
access:
description: >
Determines whether the published package should be publicly visible,
or restricted to members of your NPM organization.
required: false
dry-run:
description: Run npm with the --dry-run flag to avoid actually publishing anything.
required: false
on_finished:
description: Run a bash on finished.
required: false
on_publish_failed:
description: Run a bash on publish failed.
required: false
outputs:
failed:
description: "Random number"
value: ${{ steps.nodejs.outputs.id == '' || steps.publish_failed.outputs.failed == 'true' }}

runs:
using: 'composite'
steps:
-
uses: JS-DevTools/npm-publish@v3
id: nodejs
with:
package: assets/MAA-nodejs-package/maa-node
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-x64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-arm64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-x64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-arm64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-x64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-arm64
token: ${{ inputs.token }}
access: ${{ inputs.access }}
dry-run: ${{ inputs.dry-run }}
-
name: Finished
if: always()
shell: bash
run: |
eval $ON_FINISHED || echo "::warning::Failed to eval $ON_FINISHED"
env:
ON_FINISHED: ${{ inputs.on_finished }}
-
name: Publish Failed
id: publish_failed
if: failure() || steps.nodejs.outputs.id == ''
shell: bash
run: |
eval $ON_PUBLISH_FAILED || echo "::warning::Failed to eval $ON_PUBLISH_FAILED"
echo "failed=true" >> $GITHUB_OUTPUT
env:
ON_PUBLISH_FAILED: ${{ inputs.on_publish_failed }}
56 changes: 9 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,52 +491,14 @@ jobs:
|| eval $OUTPUT_PUBLISH_FAILED
rm -r assets/MAA-pip-pkgs
- uses: JS-DevTools/npm-publish@v3
- uses: MaaXYZ/MaaFramework/.github/actions/publish_nodejs@main
id: nodejs
with:
package: assets/MAA-nodejs-package/maa-node
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}

- name: Remove NodeJS Release
run: |
rm -r assets/MAA-nodejs-package
access: public
token: ${{ secrets.NPM_TOKEN }}
on_finished: rm -r assets/MAA-nodejs-package
on_publish_failed: ${{ env.OUTPUT_PUBLISH_FAILED }}
continue-on-error: true

- run: |
cd assets
Expand All @@ -551,7 +513,7 @@ jobs:
prerelease: ${{ needs.meta.outputs.is_pre_release == 'true' }}

- name: Create issue if failed to release
if: failure() || steps.nuget.outputs.failed || steps.pip.outputs.failed || steps.nodejs.outputs.id == 'undefined'
if: failure() || steps.nuget.outputs.failed || steps.pip.outputs.failed || steps.nodejs.outputs.failed
uses: actions-cool/issues-helper@v3
with:
actions: "create-issue"
Expand All @@ -560,6 +522,6 @@ jobs:
Please manually publish the following packages:
${{ steps.nuget.outputs.failed && '- nuget @moomiji' || '' }}
${{ steps.pip.outputs.failed && '- pip @MistEO' || '' }}
${{ steps.nodejs.outputs.id == 'undefined' && '- nodejs @neko-para' || '' }}
${{ steps.nodejs.outputs.failed && '- nodejs @neko-para' || '' }}
cc @MistEO
cc @MistEO
44 changes: 3 additions & 41 deletions .github/workflows/publish_nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,7 @@ jobs:
name: MAA-nodejs-package
path: assets/MAA-nodejs-package

- uses: JS-DevTools/npm-publish@v3
id: nodejs
- uses: MaaXYZ/MaaFramework/.github/actions/publish_nodejs@main
with:
package: assets/MAA-nodejs-package/maa-node
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-win32-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-linux-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-x64
access: public
token: ${{ secrets.NPM_TOKEN }}

- uses: JS-DevTools/npm-publish@v3
with:
package: assets/MAA-nodejs-package/maa-node-darwin-arm64
access: public
token: ${{ secrets.NPM_TOKEN }}
access: public
token: ${{ secrets.NPM_TOKEN }}

0 comments on commit 5f3b1f5

Please sign in to comment.