Skip to content

Commit 8fe3093

Browse files
authored
Create release.yml
1 parent 4f91c99 commit 8fe3093

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
8+
# Validate Repository Configuration
9+
config:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
config_package: ${{ steps.config_package.outputs.configPackage }}
13+
steps:
14+
15+
# Ensure that required repository variable has been created for the Package
16+
- name: Validate Package Config
17+
id: config_package
18+
run: |
19+
if [ "${{ vars.PACKAGE_NAME }}" != "" ]; then
20+
echo "configPackage=true" >> $GITHUB_OUTPUT;
21+
else
22+
echo "configPackage=false" >> $GITHUB_OUTPUT;
23+
fi
24+
25+
# Build and release the Package
26+
# If the repository is not configured properly, this job will be skipped
27+
build:
28+
needs: config
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
env:
33+
packagePath: ""
34+
if: needs.config.outputs.config_package == 'true'
35+
steps:
36+
37+
# Checkout Local Repository
38+
- name: Checkout
39+
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
40+
41+
# Get the Package version based on the package.json file
42+
- name: Get Version
43+
id: version
44+
uses: zoexx/github-action-json-file-properties@b9f36ce6ee6fe2680cd3c32b2c62e22eade7e590
45+
with:
46+
file_path: "package.json"
47+
prop_path: "version"
48+
49+
# Configure the Environment Variables needed for releasing the Package
50+
- name: Set Environment Variables
51+
run: |
52+
echo "zipFile=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}".zip >> $GITHUB_ENV
53+
echo "unityPackage=${{ vars.PACKAGE_NAME }}-${{ steps.version.outputs.value }}.unitypackage" >> $GITHUB_ENV
54+
echo "version=${{ steps.version.outputs.value }}" >> $GITHUB_ENV
55+
56+
# Zip the Package for release
57+
- name: Create Package Zip
58+
run: zip -r "${{ github.workspace }}/${{ env.zipFile }}" . -x '*.git/*' -x '*.github/*' -x '*.gitignore' -x '*.gitattributes' -x '*README.md*'
59+
60+
# Build a list of .meta files for future use
61+
- name: Track Package Meta Files
62+
run: find -name \*.meta >> metaList
63+
64+
# Make a UnityPackage version of the Package for release
65+
- name: Create UnityPackage
66+
uses: pCYSl5EDgo/create-unitypackage@cfcd3cf0391a5ef1306342794866a9897c32af0b
67+
with:
68+
package-path: ${{ env.unityPackage }}
69+
include-files: metaList
70+
71+
# Make a release tag of the version from the package.json file
72+
- name: Create Tag
73+
id: tag_version
74+
uses: rickstaa/action-create-tag@88dbf7ff6fe2405f8e8f6c6fdfd78829bc631f83
75+
with:
76+
tag: "${{ env.version }}"
77+
78+
# Publish the Release to GitHub
79+
- name: Make Release
80+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
81+
with:
82+
files: |
83+
${{ env.zipFile }}
84+
${{ env.unityPackage }}
85+
package.json
86+
tag_name: ${{ env.version }}

0 commit comments

Comments
 (0)