Skip to content

Commit 80245fa

Browse files
author
gaohanqing
committed
[Optimize] optimize generate change log logic in harmony publish
1 parent de559b8 commit 80245fa

File tree

2 files changed

+69
-10
lines changed

2 files changed

+69
-10
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Get Latest Ancestor Tag
2+
3+
description: Get the latest ancestor tag of the current commit.
4+
5+
outputs:
6+
latest-tag:
7+
description: 'The latest tag'
8+
value: ${{ steps.get-tag.outputs.latest-tag }}
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: get latest ancestor tag
14+
id: get-ancestor-tag
15+
shell: bash
16+
run: |
17+
set -e
18+
pwd
19+
ANCESTOR_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
20+
echo "ANCESTOR_TAG=$ANCESTOR_TAG"
21+
echo "ANCESTOR_TAG=$ANCESTOR_TAG" >> $GITHUB_ENV
22+
23+
- name: get latest tag from api
24+
id: get-latest-tag-from-api
25+
shell: bash
26+
run: |
27+
REPO="${{ github.repository }}"
28+
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name')
29+
if [ "$LATEST_TAG" = "null" ]; then
30+
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/tags" | jq -r '.[0].name')
31+
fi
32+
echo "LATEST_TAG=$LATEST_TAG"
33+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
34+
35+
- id: get-tag
36+
shell: bash
37+
run: |
38+
if [ -n "${{ env.ANCESTOR_TAG }}" ]; then
39+
FINAL_TAG="${{ env.ANCESTOR_TAG }}"
40+
else
41+
FINAL_TAG="${{ env.LATEST_TAG }}"
42+
fi
43+
44+
echo "Latest tag found: $FINAL_TAG"
45+
echo "latest-tag=$FINAL_TAG" >> $GITHUB_OUTPUT

.github/workflows/harmony-release.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
harmony-release:
1313
runs-on: lynx-container
1414
container:
15-
image: ghcr.io/lynx-family/ubuntu24.04-harmony:lastest
15+
image: ghcr.io/lynx-family/ubuntu24.04-harmony@sha256:8eb0ee8da7e8592669f0fcd41d0e1bc818b33a75e27943521f57af87d04db2fb
1616
credentials:
1717
username: lynx-family
1818
password: ${{ secrets.GITHUB_TOKEN }}
@@ -29,6 +29,12 @@ jobs:
2929
git-cliff --version
3030
- name: Download Source
3131
uses: actions/[email protected]
32+
with:
33+
fetch-depth: 0
34+
fetch-tags: true
35+
- name: Get latest tag
36+
id: get-latest-tag
37+
uses: ./.github/actions/get-latest-tag
3238
- name: Get Tag Information
3339
run: |-
3440
version="${{ github.event.inputs.tag }}"
@@ -39,6 +45,14 @@ jobs:
3945
run: |
4046
source tools/envsetup.sh
4147
hab sync . -f --target harmony
48+
- name: Generate Change Log
49+
shell: bash
50+
run: |
51+
COMMIT_ID=$(git rev-list -n 1 ${{ steps.get-latest-tag.outputs.latest-tag }})
52+
git-cliff --config harmony/primjs/cliff.toml \
53+
$COMMIT_ID..HEAD | sed 's/<!-- version -->/${{ steps.get_tag.outputs.VERSION }}/g' > harmony/primjs/CHANGELOG.md
54+
echo "CHANGELOG.md generated successfully"
55+
cat harmony/primjs/CHANGELOG.md
4256
- name: Generate Change Log
4357
shell: bash
4458
run: |
@@ -58,14 +72,14 @@ jobs:
5872
pushd harmony
5973
./scripts/build.py --modules primjs --build_type Release --build_napi_adapter --version ${{ steps.get_tag.outputs.VERSION }}
6074
pushd primjs/build/default/outputs/default
61-
ohpm publish primjs.har --publish_id ${{ secrets.HARMONY_PUBLISH_ID }} --key_path $PROJECT_ROOT/publish_key
75+
ls -la
6276
popd
6377
popd
64-
- name: Push to release
65-
uses: ncipollo/release-action@v1
66-
with:
67-
tag: ${{ steps.get_tag.outputs.VERSION }}
68-
token: ${{ secrets.GITHUB_TOKEN }}
69-
replacesArtifacts: true
70-
allowUpdates: true
71-
artifacts: "harmony/primjs/build/default/outputs/default/primjs.har"
78+
# - name: Push to release
79+
# uses: ncipollo/release-action@v1
80+
# with:
81+
# tag: ${{ steps.get_tag.outputs.VERSION }}
82+
# token: ${{ secrets.GITHUB_TOKEN }}
83+
# replacesArtifacts: true
84+
# allowUpdates: true
85+
# artifacts: "harmony/primjs/build/default/outputs/default/primjs.har"

0 commit comments

Comments
 (0)