Skip to content

Commit

Permalink
Merge branch 'main' into refactor/term
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO authored Jan 9, 2025
2 parents f61e066 + 7eb0a75 commit d1eb9f1
Show file tree
Hide file tree
Showing 41 changed files with 680 additions and 227 deletions.
87 changes: 87 additions & 0 deletions .github/actions/publish_nodejs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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') && '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 }}
91 changes: 31 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ on:
- "source/**"
- "CMakeLists.txt"
workflow_dispatch:
inputs:
build_config:
required: true
default: "Debug"
type: choice
options:
- Debug
- RelWithDebInfo
- Release

jobs:
meta:
Expand Down Expand Up @@ -91,13 +100,13 @@ jobs:
run: |
cmake --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }}" -DCMAKE_SYSTEM_VERSION="10.0.26100.0" -DMAADEPS_TRIPLET="maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-windows" -DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' -DBUILD_NODEJS_BINDING=ON
cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - RelWithDebInfo" -j 16
cmake --build build --preset "${{ matrix.arch == 'x86_64' && 'MSVC 2022' || 'MSVC 2022 ARM' }} - ${{ inputs.build_config || needs.meta.outputs.build_config }}" -j 16
- name: Install
shell: bash
if: always()
run: |
cmake --install build --prefix install --config RelWithDebInfo
cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }}
rm -rf install/bin/msvc-debug
cp -r docs install
Expand Down Expand Up @@ -180,13 +189,13 @@ jobs:
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}' \
-DBUILD_NODEJS_BINDING=ON
cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16
cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16
- name: Install
shell: bash
if: always()
run: |
cmake --install build --prefix install --config RelWithDebInfo
cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }}
cp -r docs install
cp README*.md install
Expand Down Expand Up @@ -262,13 +271,13 @@ jobs:
-DCMAKE_CXX_COMPILER=${LLVM_PREFIX}/bin/clang++ \
-DBUILD_NODEJS_BINDING=ON
cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16
cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16
- name: Install
shell: bash
if: always()
run: |
cmake --install build --prefix install --config RelWithDebInfo
cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }}
cp -r docs install
cp README*.md install
Expand Down Expand Up @@ -328,13 +337,13 @@ jobs:
-DMAADEPS_TRIPLET='maa-${{ matrix.arch == 'x86_64' && 'x64' || 'arm64' }}-android' \
-DMAA_HASH_VERSION='${{ needs.meta.outputs.tag }}'
cmake --build build --preset 'NinjaMulti - RelWithDebInfo' -j 16
cmake --build build --preset 'NinjaMulti - ${{ inputs.build_config || needs.meta.outputs.build_config }}' -j 16
- name: Install
shell: bash
if: always()
run: |
cmake --install build --prefix install --config RelWithDebInfo
cmake --install build --prefix install --config ${{ inputs.build_config || needs.meta.outputs.build_config }}
cp -r docs install
cp README*.md install
Expand All @@ -351,7 +360,7 @@ jobs:

nuget_pack:
needs: [meta, windows, ubuntu, macos, android]
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: nuget/setup-nuget@v2

Expand All @@ -362,15 +371,16 @@ jobs:

- name: Nuget Pack
working-directory: tools/nupkgs
shell: bash
run: |
wget https://raw.githubusercontent.com/MaaAssistantArknights/design/main/logo/maa-logo_128x128.png
curl -sSOL https://raw.githubusercontent.com/MaaAssistantArknights/design/main/logo/maa-logo_128x128.png
version=${{ needs.meta.outputs.version }}
for NUSPEC in Maa.Framework.Runtime*.nuspec; do
cat Head.nuspec $NUSPEC Tail.nuspec > temp && mv temp $NUSPEC
nuget pack $NUSPEC \
-Verbosity detailed \
-Properties "version=${version//-post/};year=$(date +%Y);branch=$(git rev-parse --abbrev-ref HEAD);commit=$(git rev-parse HEAD);root_path=../.."
-Properties "version=${version//-post/};year=$(date +%Y);branch=$(git rev-parse --abbrev-ref HEAD);commit=$(git rev-parse HEAD);root_path=..\.."
done
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -481,56 +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
- name: Remove win-dbg package
run: |
rm -r assets/MAA-win-dbg*
on_finished: rm -r assets/MAA-nodejs-package
on_publish_failed: ${{ env.OUTPUT_PUBLISH_FAILED }}
continue-on-error: true

- run: |
cd assets
Expand All @@ -544,13 +512,16 @@ jobs:
tag_name: ${{ needs.meta.outputs.tag }}
prerelease: ${{ needs.meta.outputs.is_pre_release == 'true' }}

- name: Create issue if failed to publish packages
if: steps.nuget.outputs.failed || steps.pip.outputs.failed
- name: Create issue if failed to release
if: failure() || steps.nuget.outputs.failed || steps.pip.outputs.failed || steps.nodejs.outputs.failed
uses: actions-cool/issues-helper@v3
with:
actions: "create-issue"
title: "${{ needs.meta.outputs.tag }} failed to publish packages"
title: "${{ needs.meta.outputs.tag }} failed to release"
body: |
Please manually publish the following packages:
${{ steps.nuget.outputs.failed && '- nuget @moomiji' || '' }}
${{ steps.pip.outputs.failed && '- pip @MistEO' || '' }}
${{ steps.nodejs.outputs.failed && '- nodejs @neko-para' || '' }}
cc @MistEO
18 changes: 16 additions & 2 deletions .github/workflows/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:
value: ${{ jobs.set.outputs.tag }}
version:
value: ${{ jobs.set.outputs.version }}

build_config:
value: ${{ jobs.set.outputs.build_config }}
jobs:
set:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -49,15 +50,28 @@ jobs:
version=${tag#v}+${commit_hash}.$(date +%Y%m%d)
fi
if $is_release; then
if $is_pre_release; then
build_config="RelWithDebInfo"
else
build_config="Release"
fi
else
build_config="Debug"
fi
echo "tag=$tag
version=$version
is_release=$is_release
is_pre_release=$is_pre_release" | tee -a "$GITHUB_OUTPUT"
is_pre_release=$is_pre_release
build_config=$build_config" | tee -a "$GITHUB_OUTPUT"
outputs:
is_release: ${{ steps.set.outputs.is_release }}
is_pre_release: ${{ steps.set.outputs.is_pre_release }}
tag: ${{ steps.set.outputs.tag }} # v<release version> | v<ci version>
version: ${{ steps.set.outputs.version }} # <release version> | <ci version>+<build> e.g ↓
build_config: ${{ steps.set.outputs.build_config }} # Release | RelWithDebInfo | Debug


# 主版本号.次版本号.修订号[-(alpha|beta|rc).预发布号]
Expand Down
40 changes: 1 addition & 39 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 }}
Loading

0 comments on commit d1eb9f1

Please sign in to comment.