1+ name : Release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : " tag: git tag you want create. (sample 1.0.0)"
8+ required : true
9+
10+ env :
11+ GIT_TAG : ${{ github.event.inputs.tag }}
12+
13+ jobs :
14+ update-packagejson :
15+ runs-on : ubuntu-latest
16+ env :
17+ TARGET_FILE : ./Assets/MackySoft/MackySoft.SerializeReferenceExtensions/package.json
18+ outputs :
19+ sha : ${{ steps.commit.outputs.sha }}
20+ steps :
21+ - uses : actions/checkout@v2
22+ - name : Output package.json (Before)
23+ run : cat ${{ env.TARGET_FILE}}
24+
25+ - name : Update package.json to version ${{ env.GIT_TAG }}
26+ run : sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }}
27+
28+ - name : Check update
29+ id : check_update
30+ run : |
31+ cat ${{ env.TARGET_FILE}}
32+ git diff --exit-code || echo "::set-output name=changed::1"
33+
34+ - name : Commit files
35+ id : commit
36+ if : steps.check_update.outputs.changed == '1'
37+ run : |
38+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+ git config --local user.name "github-actions[bot]"
40+ git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a
41+ echo "::set-output name=sha::$(git rev-parse HEAD)"
42+
43+ - name : Check sha
44+ run : echo "SHA ${SHA}"
45+ env :
46+ SHA : ${{ steps.commit.outputs.sha }}
47+
48+ - name : Create Tag
49+ if : steps.check_update.outputs.changed == '1'
50+ run : git tag ${{ env.GIT_TAG }}
51+
52+ - name : Push changes
53+ if : steps.check_update.outputs.changed == '1'
54+ uses : ad-m/github-push-action@master
55+ with :
56+ github_token : ${{ secrets.GITHUB_TOKEN }}
57+ branch : ${{ github.ref }}
58+ tags : true
59+
60+ build :
61+ needs : [update-packagejson]
62+ strategy :
63+ matrix :
64+ unity : ["2020.3.8f1"]
65+ include :
66+ - unityVersion : 2020.3.8f1
67+ license : UNITY_LICENSE_2020
68+ runs-on : ubuntu-latest
69+ timeout-minutes : 15
70+ steps :
71+ - run : echo ${{ needs.update-packagejson.outputs.sha }}
72+ - uses : actions/checkout@v2
73+ with :
74+ ref : ${{ needs.update-packagejson.outputs.sha }}
75+
76+ - name : Export unitypackage
77+ uses : game-ci/unity-builder@v2
78+ env :
79+ UNITY_LICENSE : ${{ secrets[matrix.license] }}
80+ with :
81+ projectPath : .
82+ unityVersion : ${{ matrix.unityVersion }}
83+ targetPlatform : StandaloneLinux64
84+ buildMethod : MackySoft.PackageTools.Editor.UnityPackageExporter.Export
85+ versioning : None
86+
87+ - name : check all .meta is commited
88+ run : |
89+ if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then
90+ echo "Detected .meta file generated. Do you forgot commit a .meta file?"
91+ exit 1
92+ else
93+ echo "Great, all .meta files are commited."
94+ fi
95+ working-directory : .
96+
97+ # Store artifacts.
98+ - uses : actions/upload-artifact@v2
99+ with :
100+ name : SerializeReference-Extensions.unitypackage
101+ path : ./Build/SerializeReference-Extensions.unitypackage
102+
103+ create-release :
104+ needs : [update-packagejson, build]
105+ runs-on : ubuntu-latest
106+ steps :
107+ # Create Releases
108+ - uses : actions/create-release@v1
109+ id : create_release
110+ env :
111+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
112+ with :
113+ tag_name : ${{ env.GIT_TAG }}
114+ release_name : ${{ env.GIT_TAG }}
115+ commitish : ${{ needs.update-packagejson.outputs.sha }}
116+ draft : true
117+ prerelease : false
118+
119+ # Download(All) Artifacts to current directory
120+ - uses : actions/download-artifact@v2
121+
122+ # Upload to Releases(unitypackage)
123+ - uses : actions/upload-release-asset@v1
124+ env :
125+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
126+ with :
127+ upload_url : ${{ steps.create_release.outputs.upload_url }}
128+ asset_path : ./SerializeReference-Extensions.unitypackage/SerializeReference-Extensions.unitypackage
129+ asset_name : SerializeReference-Extensions.unitypackage
130+ asset_content_type : application/octet-stream
0 commit comments