@@ -8,7 +8,38 @@ permissions:
88 contents : read
99
1010jobs :
11- build :
11+ check_changes :
12+ runs-on : ubuntu-latest
13+ outputs :
14+ harmony_changed : ${{ steps.check.outputs.changed }}
15+ prev_tag : ${{ steps.check.outputs.prev_tag }}
16+ steps :
17+ - uses : actions/checkout@v6
18+ with :
19+ fetch-depth : 0
20+ - name : Check Harmony changes
21+ id : check
22+ shell : bash
23+ run : |
24+ PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
25+ echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
26+ if [ -z "$PREV_TAG" ]; then
27+ echo "No previous tag found, assuming harmony changed."
28+ echo "changed=true" >> $GITHUB_OUTPUT
29+ exit 0
30+ fi
31+ echo "Previous tag is $PREV_TAG"
32+ if git diff --name-only "$PREV_TAG" HEAD | grep -q '^harmony/'; then
33+ echo "harmony directory changed."
34+ echo "changed=true" >> $GITHUB_OUTPUT
35+ else
36+ echo "harmony directory has NO changes."
37+ echo "changed=false" >> $GITHUB_OUTPUT
38+ fi
39+
40+ publish_with_harmony :
41+ needs : check_changes
42+ if : needs.check_changes.outputs.harmony_changed == 'true'
1243 runs-on : ubuntu-latest
1344 container : ghcr.io/sanchuanhehe/harmony-next-pipeline-docker/harmonyos-ci-image:latest
1445 timeout-minutes : 10
3970 else
4071 npm publish --provenance --access public
4172 fi
73+
74+ publish_without_harmony :
75+ needs : check_changes
76+ if : needs.check_changes.outputs.harmony_changed == 'false'
77+ runs-on : ubuntu-latest
78+ timeout-minutes : 10
79+ steps :
80+ - uses : actions/checkout@v6
81+ with :
82+ submodules : recursive
83+ - name : Configure git safe.directory
84+ run : |
85+ git config --global --add safe.directory "$GITHUB_WORKSPACE"
86+ git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$sm_path"'
87+ - uses : oven-sh/setup-bun@v2
88+ # Setup .npmrc file to publish to npm
89+ - uses : actions/setup-node@v6
90+ with :
91+ node-version : 24
92+ registry-url : ' https://registry.npmjs.org'
93+ - run : bun install --frozen-lockfile
94+ - name : Fetch previous Harmony HAR
95+ shell : bash
96+ run : |
97+ PREV_VERSION="${{ needs.check_changes.outputs.prev_tag }}"
98+ PREV_VERSION="${PREV_VERSION#v}"
99+ echo "Attempting to fetch harmony/pushy.har from react-native-update@$PREV_VERSION"
100+ npm pack react-native-update@$PREV_VERSION || true
101+ tar -xzf react-native-update-${PREV_VERSION}.tgz package/harmony/pushy.har || true
102+ if [ -f package/harmony/pushy.har ]; then
103+ mkdir -p harmony
104+ cp package/harmony/pushy.har harmony/pushy.har
105+ echo "Successfully restored pushy.har from previous release."
106+ else
107+ echo "No harmony/pushy.har found in previous release or fetch failed."
108+ fi
109+ - name : Publish to npm
110+ shell : bash
111+ run : |
112+ if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
113+ npm publish --provenance --access public --tag beta
114+ else
115+ npm publish --provenance --access public
116+ fi
0 commit comments