-
Notifications
You must be signed in to change notification settings - Fork 274
116 lines (112 loc) · 4.15 KB
/
publish.yml
File metadata and controls
116 lines (112 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Publish Package to npmjs
on:
release:
types: [published]
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
harmony_changed: ${{ steps.check.outputs.changed }}
prev_tag: ${{ steps.check.outputs.prev_tag }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check Harmony changes
id: check
shell: bash
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, assuming harmony changed."
echo "changed=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Previous tag is $PREV_TAG"
if git diff --name-only "$PREV_TAG" HEAD | grep -q '^harmony/'; then
echo "harmony directory changed."
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "harmony directory has NO changes."
echo "changed=false" >> $GITHUB_OUTPUT
fi
publish_with_harmony:
needs: check_changes
if: needs.check_changes.outputs.harmony_changed == 'true'
runs-on: ubuntu-latest
container: ghcr.io/sanchuanhehe/harmony-next-pipeline-docker/harmonyos-ci-image:latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Configure git safe.directory
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$sm_path"'
- uses: oven-sh/setup-bun@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- run: bun install --frozen-lockfile
- name: Build Harmony HAR
run: npm run build:harmony-har -- --build-mode release
- name: Verify Harmony HAR artifact
run: test -f harmony/pushy.har
- name: Publish to npm
shell: bash
run: |
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
npm publish --provenance --access public --tag beta
else
npm publish --provenance --access public
fi
publish_without_harmony:
needs: check_changes
if: needs.check_changes.outputs.harmony_changed == 'false'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Configure git safe.directory
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$sm_path"'
- uses: oven-sh/setup-bun@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
- run: bun install --frozen-lockfile
- name: Fetch previous Harmony HAR
shell: bash
run: |
PREV_VERSION="${{ needs.check_changes.outputs.prev_tag }}"
PREV_VERSION="${PREV_VERSION#v}"
echo "Attempting to fetch harmony/pushy.har from react-native-update@$PREV_VERSION"
npm pack react-native-update@$PREV_VERSION || true
tar -xzf react-native-update-${PREV_VERSION}.tgz package/harmony/pushy.har || true
if [ -f package/harmony/pushy.har ]; then
mkdir -p harmony
cp package/harmony/pushy.har harmony/pushy.har
echo "Successfully restored pushy.har from previous release."
else
echo "No harmony/pushy.har found in previous release or fetch failed."
fi
- name: Publish to npm
shell: bash
run: |
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
npm publish --provenance --access public --tag beta
else
npm publish --provenance --access public
fi