feat: replace Bash to C# Batch #391
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: Test update-packagejson | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "tag: GitHub Tag to release. ex) 1.1.0" | |
required: true | |
default: "" | |
pull_request: | |
branches: ["main"] | |
push: | |
branches: ["main"] | |
jobs: | |
set-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.set-tag.outputs.tag }} | |
steps: | |
- name: Set tag | |
id: set-tag | |
run: | | |
tag=${{ github.event_name == 'workflow_dispatch' && inputs.tag || format('1.2.{0}', github.run_number) }} | |
echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
update-packagejson: | |
needs: [set-tag] | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
uses: ./.github/workflows/update-packagejson.yaml | |
with: | |
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} | |
file-path: | | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo/package.json | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo.Plugin/package.json | |
./Sandbox/Sandbox.Godot/addons/Foo/plugin.cfg | |
./Sandbox/Directory.Build.props | |
dotnet-run-path: | |
./Sandbox/VersionOutput/VersionOutput.csproj | |
tag: ${{ needs.set-tag.outputs.tag }} | |
dry-run: true | |
# omit `dotnet-run-path` | |
update-packagejson2: | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
needs: [set-tag, update-packagejson] | |
uses: ./.github/workflows/update-packagejson.yaml | |
with: | |
ref: ${{ needs.update-packagejson.outputs.sha }} | |
file-path: | | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo/package.json | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo.Plugin/package.json | |
./Sandbox/Sandbox.Godot/addons/Foo/plugin.cfg | |
./Sandbox/Directory.Build.props | |
tag: ${{ needs.set-tag.outputs.tag }} | |
dry-run: true | |
# use v Prefixed version | |
update-packagejson3: | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
needs: [set-tag, update-packagejson2] | |
uses: ./.github/workflows/update-packagejson.yaml | |
with: | |
ref: ${{ needs.update-packagejson2.outputs.sha }} | |
file-path: | | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo/package.json | |
./Sandbox/Sandbox.Unity/Assets/Plugins/Foo.Plugin/package.json | |
./Sandbox/Sandbox.Godot/addons/Foo/plugin.cfg | |
./Sandbox/Directory.Build.props | |
tag: v${{ needs.set-tag.outputs.tag }} | |
dry-run: true | |
test: | |
needs: [set-tag, update-packagejson, update-packagejson2, update-packagejson3] | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Check update-packagejson with new version should update commit id | |
run: | | |
echo "DEBUG: tag : ${{ needs.set-tag.outputs.tag }}" | |
echo "DEBUG: github.sha : ${{ github.sha }}" | |
echo "DEBUG: update-packagejson : ${{ needs.update-packagejson.outputs.sha }}" | |
echo "DEBUG: update-packagejson2: ${{ needs.update-packagejson2.outputs.sha }}" | |
echo -n "FACT: sha for update-packagejson should be updated. " | |
if [[ "${{ needs.update-packagejson.outputs.sha }}" != "${{ github.sha }}" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: sha for update-packagejson2 should be updated. " | |
if [[ "${{ needs.update-packagejson2.outputs.sha }}" != "${{ github.sha }}" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: sha for update-packagejson and update-packagejson2 should have same commit id. " | |
if [[ "${{ needs.update-packagejson.outputs.sha }}" == "${{ needs.update-packagejson2.outputs.sha }}" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: sha for update-packagejson and update-packagejson3 should have same commit id. " | |
if [[ "${{ needs.update-packagejson.outputs.sha }}" == "${{ needs.update-packagejson3.outputs.sha }}" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: branch-name for update-packagejson should be expected. " | |
if [[ "${{ needs.update-packagejson.outputs.branch-name }}" == "test-release/${{ needs.set-tag.outputs.tag }}" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: branch-name for update-packagejson2 should be empty. " | |
if [[ "${{ needs.update-packagejson2.outputs.branch-name }}" == "" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
echo -n "FACT: branch-name for update-packagejson3 should be empty. " | |
if [[ "${{ needs.update-packagejson3.outputs.branch-name }}" == "" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | |
env: | |
HEAD_REF: ${{ github.head_ref }} | |
cleanup: | |
if: ${{ needs.update-packagejson.outputs.is-branch-created == 'true' }} | |
needs: [update-packagejson, update-packagejson3] | |
uses: ./.github/workflows/clean-packagejson-branch.yaml | |
with: | |
branch: ${{ needs.update-packagejson.outputs.branch-name }} | |
actions-timeline: | |
needs: [set-tag, update-packagejson, update-packagejson2, test] | |
uses: ./.github/workflows/actions-timeline.yaml | |
secrets: inherit |