Skip to content

Commit 3d0b5bf

Browse files
Kingatnuaa0528gaohanqing
authored andcommitted
[Optimize] optimize sdk release pipeline
1 parent 1174a5a commit 3d0b5bf

File tree

4 files changed

+117
-8
lines changed

4 files changed

+117
-8
lines changed

.github/actions/get-latest-tag/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
run: |
1717
set -e
1818
pwd
19-
ANCESTOR_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
19+
ANCESTOR_TAG=$(git describe --tags --exclude=${{ inputs.current-tag }} --abbrev=0 2>/dev/null)
2020
echo "ANCESTOR_TAG=$ANCESTOR_TAG"
2121
echo "ANCESTOR_TAG=$ANCESTOR_TAG" >> $GITHUB_ENV
2222
@@ -26,10 +26,15 @@ runs:
2626
run: |
2727
REPO="${{ github.repository }}"
2828
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')
29+
if [ "$LATEST_TAG" = "null" ] || [ "$LATEST_TAG" = "${{ inputs.current-tag }}" ]; then
30+
LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases?per_page=20" \
31+
| jq -r --arg CURRENT "${{ inputs.current-tag }}" \
32+
'.[] | select(
33+
.draft == false and
34+
.tag_name != $CURRENT
35+
) | .tag_name' \
36+
| head -n 1)
3137
fi
32-
echo "LATEST_TAG=$LATEST_TAG"
3338
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
3439
3540
- id: get-tag

.github/workflows/android-release.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,49 @@ on:
44
push:
55
tags:
66
- '*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'release tag'
11+
required: false
12+
type: string
13+
publish_release:
14+
description: 'whether to publish to github release'
15+
required: false
16+
type: boolean
17+
default: true
718

819
permissions:
920
contents: write
1021

1122
jobs:
12-
android-release:
23+
get-version:
1324
runs-on: lynx-ubuntu-22.04-medium
25+
timeout-minutes: 60
26+
outputs:
27+
version: ${{ steps.get_version.outputs.VERSION }}
28+
steps:
29+
- name: Get Version
30+
id: get_version
31+
run: |-
32+
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
33+
version=${{ github.event.inputs.tag }}
34+
else
35+
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
36+
fi
37+
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ || \
38+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ || \
39+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then
40+
echo "Version is valid"
41+
echo "VERSION=$version" >> $GITHUB_OUTPUT;
42+
else
43+
echo "Version is invalid"
44+
exit 1
45+
fi
1446
47+
android-release:
48+
runs-on: lynx-ubuntu-22.04-medium
49+
needs: get-version
1550
steps:
1651
- name: Download Source
1752
uses: actions/[email protected]
@@ -23,7 +58,7 @@ jobs:
2358

2459
- name: Get Tag Information
2560
run: |-
26-
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
61+
version=${{ needs.get-version.outputs.version }}
2762
echo "VERSION=$version" >> $GITHUB_OUTPUT;
2863
id: get_tag
2964

@@ -56,6 +91,7 @@ jobs:
5691
id: build_artifact
5792

5893
- name: Push to release
94+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_release == true) }}
5995
uses: ncipollo/release-action@v1
6096
with:
6197
tag: ${{ steps.get_tag.outputs.VERSION }}

.github/workflows/harmony-release.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,46 @@ on:
44
push:
55
tags:
66
- '*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'release tag'
11+
required: false
12+
type: string
13+
publish_release:
14+
description: 'whether to publish to github release'
15+
required: false
16+
type: boolean
17+
default: true
718

819
jobs:
20+
get-version:
21+
runs-on: lynx-ubuntu-22.04-medium
22+
timeout-minutes: 60
23+
outputs:
24+
version: ${{ steps.get_version.outputs.VERSION }}
25+
steps:
26+
- name: Get Version
27+
id: get_version
28+
run: |-
29+
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
30+
version=${{ github.event.inputs.tag }}
31+
else
32+
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
33+
fi
34+
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ || \
35+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ || \
36+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then
37+
echo "Version is valid"
38+
echo "VERSION=$version" >> $GITHUB_OUTPUT;
39+
else
40+
echo "Version is invalid"
41+
exit 1
42+
fi
43+
944
harmony-release:
1045
runs-on: lynx-container
46+
needs: get-version
1147
container:
1248
image: ghcr.io/lynx-family/ubuntu24.04-harmony@sha256:8eb0ee8da7e8592669f0fcd41d0e1bc818b33a75e27943521f57af87d04db2fb
1349
credentials:
@@ -34,7 +70,7 @@ jobs:
3470
uses: ./.github/actions/get-latest-tag
3571
- name: Get Tag Information
3672
run: |-
37-
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
73+
version=${{ needs.get-version.outputs.version }}
3874
echo "VERSION=$version" >> $GITHUB_OUTPUT;
3975
id: get_tag
4076
- name: Install deps
@@ -66,6 +102,7 @@ jobs:
66102
popd
67103
popd
68104
- name: Push to release
105+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_release == true) }}
69106
uses: ncipollo/release-action@v1
70107
with:
71108
tag: ${{ steps.get_tag.outputs.VERSION }}

.github/workflows/publish-pod.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,41 @@ on:
44
push:
55
tags:
66
- '*'
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'release tag'
11+
required: false
12+
type: string
713

814
jobs:
15+
get-version:
16+
runs-on: lynx-ubuntu-22.04-medium
17+
timeout-minutes: 60
18+
outputs:
19+
version: ${{ steps.get_version.outputs.VERSION }}
20+
steps:
21+
- name: Get Version
22+
id: get_version
23+
run: |-
24+
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
25+
version=${{ github.event.inputs.tag }}
26+
else
27+
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
28+
fi
29+
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ || \
30+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ || \
31+
$version =~ ^[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then
32+
echo "Version is valid"
33+
echo "VERSION=$version" >> $GITHUB_OUTPUT;
34+
else
35+
echo "Version is invalid"
36+
exit 1
37+
fi
38+
939
publish-pod:
1040
runs-on: macos-13
41+
needs: get-version
1142
steps:
1243
- name: Download Source
1344
uses: actions/[email protected]
@@ -16,7 +47,7 @@ jobs:
1647
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk bundle install --path .bundle
1748
- name: Get Tag Information
1849
run: |-
19-
version=$(echo ${{ github.ref }} | awk -F "/" '{print $3}')
50+
version=${{ needs.get-version.outputs.version }}
2051
echo "VERSION=$version" >> $GITHUB_OUTPUT;
2152
id: get_tag
2253
- name: Publish to CocoaPods Repo

0 commit comments

Comments
 (0)