@@ -4,151 +4,23 @@ run-name: Release common ${{ github.ref_name }} by @${{ github.actor }}
44on :
55 push :
66 tags :
7- - ' *'
7+ - ' *.*.* '
88 - ' !*alpha*'
99 - ' !*beta*'
10- - ' !*rc*'
1110
1211permissions :
1312 contents : write
1413 actions : read
1514
1615jobs :
1716 release :
18- name : Package and Release
19- runs-on : ubuntu-latest
20- outputs :
21- repo : ${{ github.repository }}
22- zip : ${{ steps.vars.outputs.zip }}
23- version : ${{ steps.vars.outputs.tag }}
24-
25- steps :
26- - name : 1️⃣ Checkout code
27- uses : actions/checkout@v5
28- with :
29- fetch-depth : 0
30-
31- - name : 2️⃣ Create ianhub-agent token
32- id : app-token
33- uses : actions/create-github-app-token@v3
34- with :
35- client-id : ${{ secrets.IANHUB_AGENT_CLIENT_ID }}
36- private-key : ${{ secrets.IANHUB_AGENT_PRIVATE_KEY }}
37- owner : ianhubnet
38-
39- - name : 3️⃣ Configure GitHub auth and identity
40- shell : bash
41- run : |
42- git config --global url."https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/".insteadOf "https://github.com/"
43- git config --global user.name "ianhub-agent[bot]"
44- git config --global user.email "ianhub-agent[bot]@users.noreply.github.com"
45-
46- - name : 4️⃣ Set up variables
47- id : vars
48- shell : bash
49- run : |
50- TAG="${GITHUB_REF#refs/tags/}"
51- ZIP="common-${TAG}.zip"
52- echo "tag=$TAG" >> $GITHUB_OUTPUT
53- echo "zip=$ZIP" >> $GITHUB_OUTPUT
54-
55- - name : 5️⃣ Prepare ZIP contents
56- shell : bash
57- run : |
58- if [ ! -d "src" ]; then
59- echo "::error::src not found"
60- exit 1
61- fi
62-
63- mkdir "common"
64- cp -r src/* "common/"
65-
66- - name : 6️⃣ Create ZIP archive
67- shell : bash
68- run : |
69- zip -r "${{ steps.vars.outputs.zip }}" "common"
70-
71- - name : 7️⃣ Create GitHub Release and upload ZIP
72- uses : softprops/action-gh-release@v3
73- with :
74- tag_name : ${{ steps.vars.outputs.tag }}
75- files : ${{ steps.vars.outputs.zip }}
76- env :
77- GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
78-
79- post-release :
80- name : Upload Common ZIP to FTP
81- needs : release
82- runs-on : ubuntu-latest
83-
84- steps :
85- - name : 1️⃣ Create ianhub-agent token
86- id : app-token
87- uses : actions/create-github-app-token@v3
88- with :
89- client-id : ${{ secrets.IANHUB_AGENT_CLIENT_ID }}
90- private-key : ${{ secrets.IANHUB_AGENT_PRIVATE_KEY }}
91- owner : ianhubnet
92-
93- - name : 2️⃣ Download release ZIP
94- shell : bash
95- run : |
96- REPO="${{ needs.release.outputs.repo }}"
97- API_URL="https://api.github.com/repos/$REPO/releases/latest"
98-
99- echo "🔍 Fetching release info..."
100- curl -s -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" "$API_URL" > release.json
101-
102- ZIP_URL=$(jq -r '.assets[] | select(.name | endswith(".zip")) | .browser_download_url' release.json)
103-
104- if [ -z "$ZIP_URL" ] || [ "$ZIP_URL" = "null" ]; then
105- echo "❌ No ZIP asset found"
106- exit 1
107- fi
108-
109- curl -L -o common.zip "$ZIP_URL"
110-
111- - name : 3️⃣ Upload common.zip to FTP
112- uses : SamKirkland/FTP-Deploy-Action@4.3.5
113- with :
114- server : ${{ secrets.FTP_HOST }}
115- port : ${{ secrets.FTP_PORT }}
116- username : ${{ secrets.FTP_USER }}
117- password : ${{ secrets.FTP_PASS }}
118- local-dir : ./
119- server-dir : ${{ secrets.FTP_PATH }}
120- state-name : " .sync-common-state.json"
121- exclude : |
122- **/*
123- !common.zip
124-
125- - name : 4️⃣ Send JSON-RPC
126- shell : bash
127- env :
128- RPC_URL : ${{ secrets.RPC_URL }}
129- RPC_KEY : ${{ secrets.RPC_KEY }}
130- RPC_VER : ${{ secrets.RPC_VER }}
131- run : |
132- REPO="${{ needs.release.outputs.repo }}"
133- VERSION="${{ needs.release.outputs.version }}"
134- REPO_URL="https://github.com/$REPO"
135- OWNER="${REPO%%/*}"
136- NAME="${REPO##*/}"
137- ID=$(openssl rand -hex 8)
138-
139- curl -s -X POST "$RPC_URL" \
140- -H "Content-Type: application/json" \
141- -H "Authorization: Bearer $RPC_KEY" \
142- -d "{
143- \"jsonrpc\": \"$RPC_VER\",
144- \"method\": \"update\",
145- \"params\": {
146- \"type\": \"common\",
147- \"package\": \"common\",
148- \"repo\": \"$REPO_URL\",
149- \"owner\": \"$OWNER\",
150- \"name\": \"$NAME\",
151- \"version\": \"$VERSION\"
152- },
153- \"id\": \"$ID\"
154- }"
17+ if : >
18+ startsWith(github.ref, 'refs/tags/') &&
19+ !contains(github.ref_name, 'alpha') &&
20+ !contains(github.ref_name, 'beta') &&
21+ !contains(github.ref_name, '+')
22+ uses : ianhubnet/.github/.github/workflows/system.yml@main
23+ with :
24+ package : common
25+ copy_docs : true
26+ secrets : inherit
0 commit comments