Skip to content

Commit 641c623

Browse files
authored
Merge pull request #25 from Cysharp/feature/actions
feat: use Cysharp/Actions reusable workflows/actions
2 parents 7b2b9d3 + 9db8d0a commit 641c623

3 files changed

Lines changed: 38 additions & 94 deletions

File tree

.github/workflows/build-debug.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- "master"
7-
tags:
8-
- "!*" # not a tag push
97
pull_request:
108
branches:
119
- "master"
@@ -26,11 +24,11 @@ jobs:
2624
runs-on: ubuntu-latest
2725
timeout-minutes: 15
2826
steps:
29-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v3
3028
# Execute scripts: RuntimeUnitTestToolkit(Linux64/Mono2x)
3129
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend Mono2x /BuildTarget StandaloneLinux64
3230
- name: Build UnitTest(Linux64, mono)
33-
uses: game-ci/unity-builder@v2.0-alpha-6
31+
uses: game-ci/unity-builder@v2
3432
env:
3533
UNITY_LICENSE: ${{ secrets[matrix.license] }}
3634
with:
@@ -46,7 +44,7 @@ jobs:
4644
# Execute scripts: Export Package
4745
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
4846
- name: Export unitypackage
49-
uses: game-ci/unity-builder@v2.0-alpha-6
47+
uses: game-ci/unity-builder@v2
5048
env:
5149
UNITY_LICENSE: ${{ secrets[matrix.license] }}
5250
with:
@@ -56,12 +54,6 @@ jobs:
5654
buildMethod: PackageExporter.Export
5755
versioning: None
5856

59-
- name: check all .meta is commited
60-
run: |
61-
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then
62-
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
63-
exit 1
64-
else
65-
echo "Great, all .meta files are commited."
66-
fi
67-
working-directory: RuntimeUnitTestToolkit
57+
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
58+
with:
59+
directory: RuntimeUnitTestToolkit

.github/workflows/build-release.yml

Lines changed: 22 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,23 @@ on:
66
tag:
77
description: "tag: git tag you want create. (sample 1.0.0)"
88
required: true
9-
dry_run:
10-
description: "dry_run: true will never create relase/nuget."
9+
dry-run:
10+
description: "dry-run: true will never create relase/nuget."
1111
required: true
12-
default: "false"
12+
default: false
13+
type: boolean
1314

1415
env:
1516
GIT_TAG: ${{ github.event.inputs.tag }}
16-
DRY_RUN: ${{ github.event.inputs.dry_run }}
17-
DRY_RUN_BRANCH_PREFIX: "test_release"
17+
DRY_RUN: ${{ github.event.inputs.dry-run }}
1818

1919
jobs:
2020
update-packagejson:
21-
runs-on: ubuntu-latest
22-
env:
23-
TARGET_FILE: ./RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit/package.json
24-
outputs:
25-
sha: ${{ steps.commit.outputs.sha }}
26-
steps:
27-
- uses: actions/checkout@v2
28-
- name: Output package.json (Before)
29-
run: cat ${{ env.TARGET_FILE}}
30-
31-
- name: Update package.json to version ${{ env.GIT_TAG }}
32-
run: sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }}
33-
34-
- name: Check update
35-
id: check_update
36-
run: |
37-
cat ${{ env.TARGET_FILE}}
38-
git diff --exit-code || echo "::set-output name=changed::1"
39-
40-
- name: Commit files
41-
id: commit
42-
if: steps.check_update.outputs.changed == '1'
43-
run: |
44-
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
45-
git config --local user.name "github-actions[bot]"
46-
git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a
47-
echo "::set-output name=sha::$(git rev-parse HEAD)"
48-
49-
- name: Check sha
50-
run: echo "SHA ${SHA}"
51-
env:
52-
SHA: ${{ steps.commit.outputs.sha }}
53-
54-
- name: Create Tag
55-
if: steps.check_update.outputs.changed == '1'
56-
run: git tag ${{ env.GIT_TAG }}
57-
58-
- name: Push changes
59-
if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1'
60-
uses: ad-m/github-push-action@master
61-
with:
62-
github_token: ${{ secrets.GITHUB_TOKEN }}
63-
branch: ${{ github.ref }}
64-
tags: true
65-
66-
- name: Push changes (dry_run)
67-
if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1'
68-
uses: ad-m/github-push-action@master
69-
with:
70-
github_token: ${{ secrets.GITHUB_TOKEN }}
71-
branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }}
72-
tags: false
21+
uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main
22+
with:
23+
file-path: ./RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit/package.json
24+
tag: ${{ github.event.inputs.tag }}
25+
dry-run: ${{ fromJson(github.event.inputs.dry-run) }}
7326

7427
build-unity:
7528
needs: [update-packagejson]
@@ -82,13 +35,13 @@ jobs:
8235
runs-on: ubuntu-latest
8336
timeout-minutes: 15
8437
steps:
85-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v3
8639
with:
8740
ref: ${{ needs.update-packagejson.outputs.sha }}
8841
# Execute scripts: Export Package
8942
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
9043
- name: Export unitypackage
91-
uses: game-ci/unity-builder@v2.0-alpha-6
44+
uses: game-ci/unity-builder@v2
9245
env:
9346
UNITY_PACKAGE_VERSION: ${{ env.GIT_TAG }}
9447
UNITY_LICENSE: ${{ secrets[matrix.license] }}
@@ -99,15 +52,9 @@ jobs:
9952
buildMethod: PackageExporter.Export
10053
versioning: None
10154

102-
- name: check all .meta is commited
103-
run: |
104-
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then
105-
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
106-
exit 1
107-
else
108-
echo "Great, all .meta files are commited."
109-
fi
110-
working-directory: RuntimeUnitTestToolkit
55+
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
56+
with:
57+
directory: RuntimeUnitTestToolkit
11158

11259
# Store artifacts.
11360
- uses: actions/upload-artifact@v1
@@ -116,9 +63,10 @@ jobs:
11663
path: ./RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.${{ env.GIT_TAG }}.unitypackage
11764

11865
create-release:
119-
if: github.event.inputs.dry_run == 'false'
66+
if: github.event.inputs.dry-run == 'false'
12067
needs: [update-packagejson, build-unity]
12168
runs-on: ubuntu-latest
69+
timeout-minutes: 10
12270
steps:
12371
# Create Release
12472
- uses: actions/create-release@v1
@@ -144,14 +92,8 @@ jobs:
14492
asset_content_type: application/octet-stream
14593

14694
cleanup:
147-
if: github.event.inputs.dry_run == 'true'
148-
needs: [build-unity]
149-
runs-on: ubuntu-latest
150-
env:
151-
GIT_TAG: ${{ github.event.inputs.tag }}
152-
steps:
153-
- name: Delete branch
154-
uses: dawidd6/action-delete-branch@v3
155-
with:
156-
github_token: ${{ github.token }}
157-
branches: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }}
95+
if: needs.update-packagejson.outputs.is-branch-created == 'true'
96+
needs: [update-packagejson, build-unity]
97+
uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main
98+
with:
99+
branch: ${{ needs.update-packagejson.outputs.branch-name }}

.github/workflows/stale.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Close stale issues"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
stale:
10+
uses: Cysharp/Actions/.github/workflows/stale-issue.yaml@main

0 commit comments

Comments
 (0)