Release #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "tag: git tag you want create. (sample 1.0.0)" | |
required: true | |
dry_run: | |
description: "dry_run: true will never create relase/nuget." | |
required: true | |
default: "false" | |
env: | |
GIT_TAG: ${{ github.event.inputs.tag }} | |
DRY_RUN: ${{ github.event.inputs.dry_run }} | |
DRY_RUN_BRANCH_PREFIX: "test_release" | |
BUILD_CONFIG: Release | |
jobs: | |
update-packagejson: | |
runs-on: ubuntu-latest | |
env: | |
TARGET_FILE: ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/package.json | |
outputs: | |
sha: ${{ steps.commit.outputs.sha }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Output package.json (Before) | |
run: cat ${{ env.TARGET_FILE}} | |
- name: Update package.json to version ${{ env.GIT_TAG }} | |
run: sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }} | |
- name: Check update | |
id: check_update | |
run: | | |
cat ${{ env.TARGET_FILE}} | |
git diff --exit-code || echo "::set-output name=changed::1" | |
- name: Commit files | |
id: commit | |
if: steps.check_update.outputs.changed == '1' | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "feat: Update package.json to ${{ env.GIT_TAG }}" -a | |
echo "::set-output name=sha::$(git rev-parse HEAD)" | |
- name: Check sha | |
run: echo "SHA ${SHA}" | |
env: | |
SHA: ${{ steps.commit.outputs.sha }} | |
- name: Create Tag | |
if: steps.check_update.outputs.changed == '1' | |
run: git tag ${{ env.GIT_TAG }} | |
- name: Push changes | |
if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
tags: true | |
- name: Push changes (dry_run) | |
if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} | |
tags: false | |
update-sourcegenerator-unity: | |
name: Update MagicOnion.Client.SourceGenerator.Unity | |
needs: [update-packagejson] | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- run: echo ${{ needs.update-packagejson.outputs.sha }} | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.update-packagejson.outputs.sha }} | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- name: Publish MagicOnion.Client.SourceGenerator.Unity | |
run: dotnet publish -c ${{ env.BUILD_CONFIG }} ./src/MagicOnion.Client.SourceGenerator.Unity -o ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity | |
- name: Remove .deps.json and .pdbs | |
run: | | |
rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.deps.json | |
rm -f ./src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MagicOnion.Client.SourceGenerator.Unity/*.pdb | |
- name: Check update | |
id: check_update | |
run: | | |
git diff --exit-code || echo "::set-output name=changed::1" | |
- name: Commit files | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "feat: Update MagicOnion.Client.SourceGenerator.Unity" -a | |
echo "::set-output name=sha::$(git rev-parse HEAD)" | |
- name: Check sha | |
run: echo "SHA ${SHA}" | |
env: | |
SHA: ${{ steps.commit.outputs.sha }} | |
- name: Create Tag | |
if: steps.check_update.outputs.changed == '1' | |
run: git tag ${{ env.GIT_TAG }} | |
- name: Push changes | |
if: env.DRY_RUN == 'false' && steps.check_update.outputs.changed == '1' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
tags: true | |
- name: Push changes (dry_run) | |
if: env.DRY_RUN == 'true' && steps.check_update.outputs.changed == '1' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} | |
tags: false | |
build-dotnet: | |
needs: [update-packagejson] | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- run: echo ${{ needs.update-packagejson.outputs.sha }} | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.update-packagejson.outputs.sha }} | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
- run: dotnet build -c ${{ env.BUILD_CONFIG }} ./MagicOnion.sln | |
# pack nuget | |
- run: dotnet pack -c ${{ env.BUILD_CONFIG }} ./MagicOnion.Packaging.slnf --include-symbols --include-source --no-build -o ./publish | |
- uses: actions/upload-artifact@v1 | |
with: | |
name: nuget | |
path: ./publish/ | |
build-unity: | |
needs: [update-packagejson] | |
strategy: | |
matrix: | |
unity: ["2021.3.0f1"] | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.update-packagejson.outputs.sha }} | |
# execute scripts/Export Package | |
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export | |
- name: Build Unity (.unitypacakge) | |
uses: Cysharp/Actions/.github/actions/unity-builder@main | |
env: | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} | |
UNITY_PACKAGE_VERSION: ${{ env.GIT_TAG }} | |
with: | |
projectPath: src/MagicOnion.Client.Unity | |
unityVersion: ${{ matrix.unity }} | |
targetPlatform: StandaloneLinux64 | |
buildMethod: PackageExporter.Export | |
- uses: ./.github/actions/check-metas | |
with: | |
directory: src/MagicOnion.Client.Unity | |
# Store artifacts. | |
- uses: actions/upload-artifact@v1 | |
with: | |
name: MagicOnion.Client.Unity.unitypackage | |
path: ./src/MagicOnion.Client.Unity/MagicOnion.Client.Unity.unitypackage | |
create-release: | |
if: github.event.inputs.dry_run == 'false' | |
needs: | |
[update-packagejson, update-sourcegenerator-unity, build-dotnet, build-unity] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.update-packagejson.outputs.sha }} | |
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main | |
# Create Release | |
- uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.GIT_TAG }} | |
release_name: Ver.${{ env.GIT_TAG }} | |
commitish: ${{ needs.update-packagejson.outputs.sha }} | |
draft: true | |
prerelease: false | |
- uses: actions/download-artifact@v2-preview | |
# Upload to NuGet | |
- run: dotnet nuget push "./nuget/*.nupkg" --skip-duplicate -s https://www.nuget.org/api/v2/package -k ${{ secrets.NUGET_KEY }} | |
- run: dotnet nuget push "./nuget-experimental/*.nupkg" --skip-duplicate -s https://www.nuget.org/api/v2/package -k ${{ secrets.NUGET_KEY }} | |
# Upload to Releases(unitypackage) | |
- uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./MagicOnion.Client.Unity.unitypackage/MagicOnion.Client.Unity.unitypackage | |
asset_name: MagicOnion.Client.Unity.unitypackage | |
asset_content_type: application/octet-stream | |
cleanup: | |
if: github.event.inputs.dry_run == 'true' | |
needs: [build-dotnet, build-unity] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete branch | |
uses: dawidd6/action-delete-branch@v3 | |
with: | |
github_token: ${{ github.token }} | |
branches: ${{ env.DRY_RUN_BRANCH_PREFIX }}-${{ env.GIT_TAG }} |