Skip to content

Commit

Permalink
Merge pull request #86 from Cysharp/feature/actions
Browse files Browse the repository at this point in the history
feat: use Cysharp/Actions reusable workflows/actions
  • Loading branch information
guitarrapc committed Jul 25, 2022
2 parents 5c8794f + 1c831ef commit 188512b
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 135 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- "master"
tags:
- "!*" # not a tag push
pull_request:
branches:
- master
Expand All @@ -32,10 +30,16 @@ jobs:
ports:
- 4222:4222
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
- run: dotnet build ./tools/PostBuildUtility/ -c Debug
- run: dotnet build -c Debug
- run: dotnet test -c Debug --no-build < /dev/null
- run: dotnet test -c Debug --no-build
# Store artifacts.
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -82,18 +86,12 @@ jobs:
buildMethod: PackageExporter.Export
versioning: None

- name: check all .meta is commited
run: |
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
exit 1
else
echo "Great, all .meta files are commited."
fi
working-directory: src/MessagePipe.Unity
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
with:
directory: src/MessagePipe.Unity

# Store artifacts.
- uses: actions/upload-artifact@v2
with:
name: MessagePipe.unitypackage-${{ matrix.unity }}.zip
path: ./src/MessagePipe.Unity/*.unitypackage
name: MessagePipe.${{ matrix.unity }}.unitypackage.zip
path: ./src/MessagePipe.Unity/*.unitypackage
133 changes: 31 additions & 102 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,93 +6,33 @@ on:
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."
dry-run:
description: "dry-run: true will never create relase/nuget."
required: true
default: "false"
default: false
type: boolean

env:
GIT_TAG: ${{ github.event.inputs.tag }}
DRY_RUN: ${{ github.event.inputs.dry_run }}
DRY_RUN: ${{ github.event.inputs.dry-run }}
DRY_RUN_BRANCH_PREFIX: "test_release"

jobs:
update-packagejson:
runs-on: ubuntu-latest
env:
TARGET_FILE: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe/package.json
TARGET_FILE2: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.VContainer/package.json
TARGET_FILE3: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Zenject/package.json
TARGET_FILE4: ./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Interprocess/package.json
outputs:
sha: ${{ steps.commit.outputs.sha }}
steps:
- uses: actions/checkout@v2
- name: Output package.json (Before)
run: |
cat ${{ env.TARGET_FILE}}
cat ${{ env.TARGET_FILE2}}
cat ${{ env.TARGET_FILE3}}
cat ${{ env.TARGET_FILE4}}
- name: Update package.json to version ${{ env.GIT_TAG }}
run: |
sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE }}
sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE2 }}
sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE3 }}
sed -i -e "s/\(\"version\":\) \"\(.*\)\",/\1 \"${{ env.GIT_TAG }}\",/" ${{ env.TARGET_FILE4 }}
- name: Check update
id: check_update
run: |
cat ${{ env.TARGET_FILE}}
cat ${{ env.TARGET_FILE2}}
cat ${{ env.TARGET_FILE3}}
cat ${{ env.TARGET_FILE4}}
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
uses: Cysharp/Actions/.github/workflows/update-packagejson.yaml@main
with:
file-path: |
./src/MessagePipe.Unity/Assets/Plugins/MessagePipe/package.json
./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.VContainer/package.json
./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Zenject/package.json
./src/MessagePipe.Unity/Assets/Plugins/MessagePipe.Interprocess/package.json
tag: ${{ github.event.inputs.tag }}
dry-run: ${{ fromJson(github.event.inputs.dry-run) }}

build-dotnet:
needs: [update-packagejson]
runs-on: ubuntu-latest
timeout-minutes: 10
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
services:
redis:
image: redis
Expand All @@ -112,15 +52,17 @@ jobs:
- uses: actions/checkout@v2
with:
ref: ${{ needs.update-packagejson.outputs.sha }}
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
# build and pack
- run: dotnet build ./tools/PostBuildUtility/ -c Release
- run: dotnet build -c Release -p:Version=${{ env.GIT_TAG }}
- run: dotnet test -c Release --no-build
- run: dotnet pack ./src/MessagePipe/MessagePipe.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
- run: dotnet pack ./src/MessagePipe.Analyzer/MessagePipe.Analyzer.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
- run: dotnet pack ./src/MessagePipe.Redis/MessagePipe.Redis.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
- run: dotnet pack ./src/MessagePipe.Interprocess/MessagePipe.Interprocess.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
- run: dotnet pack ./src/MessagePipe.Nats/MessagePipe.Nats.csproj -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
- run: dotnet pack -c Release --no-build -p:Version=${{ env.GIT_TAG }} -o ./publish
# Store artifacts.
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -161,15 +103,9 @@ jobs:
buildMethod: PackageExporter.Export
versioning: None

- name: check all .meta is commited
run: |
if git ls-files --others --exclude-standard -t | grep --regexp='[.]meta$'; then
echo "Detected .meta file generated. Do you forgot commit a .meta file?"
exit 1
else
echo "Great, all .meta files are commited."
fi
working-directory: src/MessagePipe.Unity
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
with:
directory: src/MessagePipe.Unity

# Store artifacts.
- uses: actions/upload-artifact@v2
Expand All @@ -179,14 +115,11 @@ jobs:
if-no-files-found: error

create-release:
if: github.event.inputs.dry_run == 'false'
if: github.event.inputs.dry-run == 'false'
needs: [update-packagejson, build-dotnet, build-unity]
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
NUGET_XMLDOC_MODE: skip
steps:
- uses: Cysharp/Actions/.github/actions/setup-dotnet@main
# Create Releases
- uses: actions/create-release@v1
id: create_release
Expand Down Expand Up @@ -245,12 +178,8 @@ jobs:
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 }}
if: needs.update-packagejson.outputs.is-branch-created == 'true'
needs: [update-packagejson, build-unity]
uses: Cysharp/Actions/.github/workflows/clean-packagejson-branch.yaml@main
with:
branch: ${{ needs.update-packagejson.outputs.branch-name }}
18 changes: 2 additions & 16 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
name: "Close stale issues"

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# enable issue
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days."
stale-issue-label: "stale"
# enable pr
stale-pr-message: "This PR is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days."
stale-pr-label: "stale"
days-before-stale: 90
days-before-close: 7
exempt-issue-labels: "wip"
exempt-pr-labels: "wip"
remove-stale-when-updated: true
uses: Cysharp/Actions/.github/workflows/stale-issue.yaml@main
1 change: 1 addition & 0 deletions sandbox/InterprocessServer/InterprocessServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;WinBenchmark</Configurations>
<SignAssembly>true</SignAssembly>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/MessagePipe.Analyzer/MessagePipe.Analyzer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageTags>analyzer;</PackageTags>
<Description>Analyzers of MessagePipe to prevent subscription leak.</Description>
<SignAssembly>true</SignAssembly>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand All @@ -33,4 +34,4 @@
<TfmSpecificPackageFile Include="@(SatelliteDllsProjectOutputGroupOutput->'%(FinalOutputPath)')" PackagePath="analyzers\dotnet\cs\%(SatelliteDllsProjectOutputGroupOutput.Culture)\" />
</ItemGroup>
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageTags>pubsub;eventaggregator</PackageTags>
<Description>Interprocess extensions for MessagePipe.</Description>
<SignAssembly>true</SignAssembly>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/MessagePipe.Nats/MessagePipe.Nats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageTags>pubsub;eventaggregator</PackageTags>
<Description>Nats IDistributedPublisher/Subscriber provider for MessagePipe.</Description>
<SignAssembly>true</SignAssembly>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/MessagePipe.Redis/MessagePipe.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageTags>pubsub;eventaggregator</PackageTags>
<Description>Redis IDistributedPublisher/Subscriber provider for MessagePipe.</Description>
<SignAssembly>true</SignAssembly>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/MessagePipe/MessagePipe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageTags>pubsub;eventaggregator</PackageTags>
<Description>High performance in-memory/distributed messaging pipeline for .NET and Unity.</Description>
<SignAssembly>true</SignAssembly>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -49,4 +50,4 @@
<!-- After copy, replace for unity codes -->
<Exec Command="dotnet run --no-build -c $(ConfigurationName) --project $(MSBuildProjectDirectory)\..\..\tools\PostBuildUtility\PostBuildUtility.csproj -- replace-to-unity $(DestinationRoot)" />
</Target>
</Project>
</Project>
1 change: 1 addition & 0 deletions tests/MessagePipe.Benchmark/MessagePipe.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;WinBenchmark</Configurations>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'WinBenchmark'">
<DefineConstants>RELEASE;WinBenchmark</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions tools/PostBuildUtility/PostBuildUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Configurations>Debug;Release;WinBenchmark</Configurations>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 188512b

Please sign in to comment.