1- name : generate and publish manifest
1+ name : Generate and Publish Manifest
22
33on :
44 push :
55 tags : [ 'v*' ]
6+ pull_request :
7+ types : [closed]
8+ branches : [main, master]
69
710permissions :
811 contents : write
912
1013jobs :
11- generate-manifest-json :
14+ publish :
1215 runs-on : ubuntu-latest
16+ if : github.event_name == 'push' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release v'))
1317 steps :
14- - name : Set repo name
15- run : |
16- echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
17- echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
18- - uses : actions/checkout@v5
19-
20- - name : Set up Lua
21- uses : leafo/gh-actions-lua@v12
22- with :
23- luaVersion : ' 5.3.5'
18+ - name : Checkout code
19+ uses : actions/checkout@v4
2420
25- - name : Install dependencies
21+ - name : Extract version from tag
22+ if : github.event_name == 'push'
2623 run : |
27- sudo apt-get install luarocks
28- sudo luarocks install dkjson
24+ VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)
25+ echo "VERSION=$VERSION" >> $GITHUB_ENV
2926
30- - name : Generate manifest
27+ - name : Extract version from PR title
28+ if : github.event_name == 'pull_request'
3129 run : |
32- sudo lua -e '
33- require("metadata");
34- local dkjson = require("dkjson");
35- PLUGIN.downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.REPO_NAME }}-${{ env.VERSION }}.zip";
36- local str = dkjson.encode(PLUGIN);
37- print(str)' > manifest.json
38- cat manifest.json
39- - name : Upload JSON file
40- uses : actions/upload-artifact@v4
41- with :
42- name : manifest
43- path : manifest.json
44- release-plugin-and-manifest :
45- needs : generate-manifest-json
46- runs-on : ubuntu-latest
47- steps :
48- - name : Set repo name
30+ PR_TITLE="${{ github.event.pull_request.title }}"
31+ VERSION=$(echo "$PR_TITLE" | grep -oP 'Release v\K[0-9]+\.[0-9]+\.[0-9]+')
32+ echo "VERSION=$VERSION" >> $GITHUB_ENV
33+
34+ - name : Validate version
4935 run : |
50- echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
51- echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
52- - name : Checkout code
53- uses : actions/checkout@v5
54- - name : Download JSON file
55- uses : actions/download-artifact@v5
56- with :
57- name : manifest
58- - name : Compress build files
59- uses : thedoctor0/zip-release@0.7.6
60- with :
61- type : " zip"
62- directory : " ./"
63- filename : " ${{ env.REPO_NAME }}-${{ env.VERSION }}.zip"
64- exclusions : " *.git* manifest.json"
65- - name : Publish release
66- uses : svenstaro/upload-release-action@v2
67- with :
68- repo_token : ${{ secrets.GITHUB_TOKEN }}
69- file : ./${{ env.REPO_NAME }}-${{ env.VERSION }}.zip
70- tag : v${{ env.VERSION }}
71- file_glob : true
72- - name : Publish manifest
73- uses : svenstaro/upload-release-action@v2
36+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
37+ echo "Invalid version format: $VERSION"
38+ exit 1
39+ fi
40+ echo "Publishing version: $VERSION"
41+
42+ - name : Publish manifest and release
43+ uses : version-fox/plugin-manifest-action@main
7444 with :
75- repo_token : ${{ secrets.GITHUB_TOKEN }}
76- file : ./manifest.json
77- tag : " manifest"
78- overwrite : true
79- file_glob : true
45+ version : ${{ env.VERSION }}
46+ github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments