1- name : generate and publish manifest
1+ name : Generate and Publish Manifest
22
33on :
44 push :
55 tags : [ 'v*' ]
6- workflow_dispatch :
7- inputs :
8- version :
9- description : ' Version to release (e.g., 1.0.0)'
10- required : true
11- type : string
6+ pull_request :
7+ types : [closed]
8+ branches : [main, master]
129
1310permissions :
1411 contents : write
1512
1613jobs :
17- generate-manifest-json :
14+ publish :
1815 runs-on : ubuntu-latest
16+ if : github.event_name == 'push' || (github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release v'))
1917 steps :
20- - name : Set repo name
21- run : |
22- echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
23- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
24- echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
25- else
26- echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
27- fi
28- - uses : actions/checkout@v5
29-
30- - name : Set up Lua
31- uses : leafo/gh-actions-lua@v12
32- with :
33- luaVersion : ' 5.3.5'
18+ - name : Checkout code
19+ uses : actions/checkout@v4
3420
35- - name : Install dependencies
21+ - name : Extract version from tag
22+ if : github.event_name == 'push'
3623 run : |
37- sudo apt-get install luarocks
38- sudo luarocks install dkjson
24+ VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)
25+ echo "VERSION=$VERSION" >> $GITHUB_ENV
3926
40- - name : Generate manifest
27+ - name : Extract version from PR title
28+ if : github.event_name == 'pull_request'
4129 run : |
42- sudo lua -e '
43- require("metadata");
44- local dkjson = require("dkjson");
45- PLUGIN.downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.REPO_NAME }}-${{ env.VERSION }}.zip";
46- local str = dkjson.encode(PLUGIN);
47- print(str)' > manifest.json
48- cat manifest.json
49- - name : Upload JSON file
50- uses : actions/upload-artifact@v4
51- with :
52- name : manifest
53- path : manifest.json
54- release-plugin-and-manifest :
55- needs : generate-manifest-json
56- runs-on : ubuntu-latest
57- steps :
58- - 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
5935 run : |
60- echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV
61- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
62- echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
63- else
64- echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
36+ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
37+ echo "Invalid version format: $VERSION"
38+ exit 1
6539 fi
66- - name : Checkout code
67- uses : actions/checkout@v5
68- - name : Download JSON file
69- uses : actions/download-artifact@v5
70- with :
71- name : manifest
72- - name : Compress build files
73- uses : thedoctor0/zip-release@0.7.6
74- with :
75- type : " zip"
76- directory : " ./"
77- filename : " ${{ env.REPO_NAME }}-${{ env.VERSION }}.zip"
78- exclusions : " *.git* manifest.json"
79- - name : Publish release
80- uses : svenstaro/upload-release-action@v2
81- with :
82- repo_token : ${{ secrets.GITHUB_TOKEN }}
83- file : ./${{ env.REPO_NAME }}-${{ env.VERSION }}.zip
84- tag : v${{ env.VERSION }}
85- file_glob : true
86- - name : Publish manifest
87- uses : svenstaro/upload-release-action@v2
40+ echo "Publishing version: $VERSION"
41+
42+ - name : Publish manifest and release
43+ uses : version-fox/plugin-manifest-action@main
8844 with :
89- repo_token : ${{ secrets.GITHUB_TOKEN }}
90- file : ./manifest.json
91- tag : " manifest"
92- overwrite : true
93- file_glob : true
45+ version : ${{ env.VERSION }}
46+ github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments