Skip to content

Commit 0b97b55

Browse files
authored
Merge pull request #106 from IShix-g/release
Release
2 parents b2d20f7 + 103c82d commit 0b97b55

File tree

2 files changed

+143
-4
lines changed

2 files changed

+143
-4
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build Package Exporter
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Git tag you want to create (e.g., 1.0.0).'
8+
required: true
9+
type: string
10+
unity-version:
11+
description: 'Select the Unity version to use'
12+
required: true
13+
default: '2021.3.45f1'
14+
type: choice
15+
options:
16+
- '2021.3.45f1'
17+
- '2022.3.57f1'
18+
- '6000.0.37f1'
19+
dry-run:
20+
description: 'Dry Run: Set to true to simulate the merge without committing or pushing changes.'
21+
type: boolean
22+
default: false
23+
24+
env:
25+
PACKAGE_NAME: PackageExporter
26+
27+
jobs:
28+
extract-tag:
29+
if: ${{ github.ref == github.event.repository.default_branch }}
30+
runs-on: ubuntu-22.04
31+
steps:
32+
- name: Extract tag from Pull Request title
33+
id: extract-tag
34+
run: |
35+
echo "::error::Please specify a branch other than the default branch."
36+
exit 1
37+
38+
get-latest-release:
39+
needs: extract-tag
40+
runs-on: ubuntu-22.04
41+
outputs:
42+
release: ${{ steps.latest-release.outputs.release }}
43+
steps:
44+
- name: Checkout Code
45+
uses: actions/checkout@v4
46+
47+
- name: Install GitHub CLI
48+
run: |
49+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
50+
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
51+
echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
52+
sudo apt update
53+
sudo apt install gh -y
54+
55+
- name: Verify GitHub CLI Installation
56+
run: gh --version
57+
58+
- name: Get Latest Release
59+
id: latest-release
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
latest_release=$(gh release view --json tagName -q ".tagName")
64+
echo "release=$latest_release" >> "$GITHUB_OUTPUT"
65+
echo "::notice title=Latest release::$latest_release"
66+
67+
check-existing-package:
68+
needs: get-latest-release
69+
runs-on: ubuntu-22.04
70+
steps:
71+
- name: Check for Existing Package
72+
id: check-package
73+
run: |
74+
latest_release="${{ needs.get-latest-release.outputs.release }}"
75+
file_name="${{ env.PACKAGE_NAME }}_*.unitypackage"
76+
asset_url=$(gh release view "$latest_release" --json assets -q ".assets[].name" | grep -E "$file_name" || echo "")
77+
if [[ -n "$asset_url" ]]; then
78+
echo "::notice title=Found file::$asset_url"
79+
echo "found=1" >> "$GITHUB_OUTPUT"
80+
fi
81+
82+
- name: Delete Existing Package File
83+
if: ${{ steps.check-package.outputs.found == '1' }}
84+
run: |
85+
latest_release="${{ needs.get-latest-release.outputs.release }}"
86+
file_name="${{ env.PACKAGE_NAME }}_*.unitypackage"
87+
current_file_name=$(gh release view "$latest_release" --json assets -q ".assets[].name" | grep -E "$file_name")
88+
if [[ -n "$current_file_name" ]]; then
89+
gh release delete-asset "$latest_release" "$current_file_name"
90+
echo "::notice title=Removed asset::$current_file_name"
91+
else
92+
echo "::notice title=Not removed asset::No matching asset found to remove."
93+
fi
94+
95+
update-packagejson:
96+
needs: check-existing-package
97+
uses: .github/workflows/reusable-update-packagejson.yaml
98+
secrets:
99+
BOT_APP_ID: ${{ secrets.BOT_APP_ID }}
100+
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
101+
with:
102+
ref: ${{ github.ref }}
103+
file-path: ./Assets/Plugins/PackageExporter/package.json
104+
tag: ${{ inputs.tag }}
105+
dry-run: ${{ inputs.dry-run }}
106+
107+
build-package:
108+
needs: update-packagejson
109+
uses: .github/workflows/reusable-build-package.yaml
110+
secrets:
111+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
112+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
113+
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
114+
with:
115+
package-name: ${{ env.PACKAGE_NAME }}
116+
tag: ${{ needs.update-package-json.outputs.normalized-tag }}
117+
unity-version: ${{ inputs.unity-version }}
118+
commit-id: ${{ needs.update-package-json.outputs.sha }}
119+
120+
merge-and-push:
121+
needs: update-packagejson
122+
if: ${{ needs.update-package-json.outputs.changed == '1' }}
123+
uses: .github/workflows/reusable-merge-and-push.yaml
124+
secrets:
125+
BOT_APP_ID: ${{ secrets.BOT_APP_ID }}
126+
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
127+
with:
128+
target-branch: ${{ github.ref }}
129+
push-branch: ${{ github.event.repository.default_branch }}
130+
commit-id: ${{ needs.update-package-json.outputs.sha }}
131+
dry-run: ${{ inputs.dry-run }}
132+
133+
upload-package:
134+
needs: [build-package, merge-and-push]
135+
runs-on: ubuntu-22.04
136+
steps:
137+
- name: Upload New Package
138+
run: |
139+
new_file="${{ needs.build-package.outputs.export-path }}"
140+
latest_release="${{ needs.get-latest-release.outputs.release }}"
141+
gh release upload "$latest_release" "$new_file"
142+
echo "::notice title=Uploaded new asset::$new_file"

Assets/Plugins/PackageExporter/Editor/PackageExporterSetting.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ public static PackageExporterSetting Instance
1818
{
1919
if (s_instance == default)
2020
{
21-
s_instance = Load();
21+
s_instance = AssetDatabaseSupport.CreateOrLoad<PackageExporterSetting>(AssetPath);
2222
}
2323
return s_instance;
2424
}
2525
}
2626
static PackageExporterSetting s_instance;
2727

28-
public static PackageExporterSetting Load()
29-
=> AssetDatabaseSupport.CreateOrLoad<PackageExporterSetting>(AssetPath);
30-
3128
public void SetFolderPath(string path)
3229
{
3330
_folderPath = path;

0 commit comments

Comments
 (0)