Update VContainerAnalyzer.dll #246
Workflow file for this run
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: Release | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- closed | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PACKAGE_JSON_PATH: VContainerAnalyzer.Unity/Assets/Plugins/VContainerAnalyzer/package.json | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
paths: | |
name: paths | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
outputs: | |
package_json: ${{ steps.filter.outputs.package_json }} | |
steps: | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
package_json: | |
- ${{ env.PACKAGE_JSON_PATH }} | |
draft: | |
name: draft | |
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch'}} | |
runs-on: ubuntu-latest | |
outputs: | |
tag_name: ${{ steps.release_drafter.outputs.tag_name }} | |
steps: | |
- uses: release-drafter/release-drafter@v6 | |
id: release_drafter | |
with: | |
commitish: main | |
update-files: | |
name: update-files | |
needs: draft | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.draft.outputs.tag_name }} | |
SOURCE_BRANCH: github-actions/update-files/${{ github.run_number }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Update package.json | |
shell: pwsh | |
run: | | |
$jsonContent = Get-Content -Path $env:PACKAGE_JSON_PATH | ConvertFrom-Json | |
$jsonContent.version = $env:VERSION | |
$jsonContent | ConvertTo-Json | Set-Content -Path $env:PACKAGE_JSON_PATH | |
- name: Confirm package.json diff | |
id: package-json | |
run: | | |
git add "${PACKAGE_JSON_PATH}" | |
result=0 | |
git diff --cached --exit-code --quiet || result=$? | |
if [ "${result}" -eq 0 ]; then | |
echo "diff=false" >> "${GITHUB_OUTPUT}" | |
elif [ "${result}" -eq 1 ]; then | |
echo "diff=true" >> "${GITHUB_OUTPUT}" | |
else | |
echo "exit code of diff is unknown: ${result}" | |
exit 1 | |
fi | |
- name: Commit package.json | |
if: ${{ steps.package-json.outputs.diff == 'true' }} | |
run: | | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git config user.name github-actions[bot] | |
git switch -C "${SOURCE_BRANCH}" | |
git commit -m "Update package.json" | |
git push -u origin "${SOURCE_BRANCH}" | |
- name: Update README.md | |
run: | | |
cp -f .github/DRAFT_README.md README.md | |
- name: Confirm README.md diff | |
id: readme | |
run: | | |
git add README.md | |
result=0 | |
git diff --cached --exit-code --quiet || result=$? | |
if [ "${result}" -eq 0 ]; then | |
echo "diff=false" >> "${GITHUB_OUTPUT}" | |
elif [ "${result}" -eq 1 ]; then | |
echo "diff=true" >> "${GITHUB_OUTPUT}" | |
else | |
echo "exit code of diff is unknown: ${result}" | |
exit 1 | |
fi | |
- name: Commit README.md | |
if: ${{ steps.readme.outputs.diff == 'true' }} | |
run: | | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git config user.name github-actions[bot] | |
git switch -C "${SOURCE_BRANCH}" | |
git commit -m "Update README.md" | |
git push -u origin "${SOURCE_BRANCH}" | |
- name: Create pull request and merge | |
if: ${{ steps.package-json.outputs.diff == 'true' || steps.readme.outputs.diff == 'true' }} | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
gh pr create --title "Update files for release" --body "Update files for release" --base main --head "${SOURCE_BRANCH}" | |
gh pr merge "${SOURCE_BRANCH}" --auto --merge | |
release: | |
name: release | |
needs: [draft, paths] | |
environment: release | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged && needs.paths.outputs.package_json == 'true' }} | |
env: | |
VERSION: ${{ needs.draft.outputs.tag_name }} | |
steps: | |
- uses: release-drafter/release-drafter@v6 | |
id: release-drafter | |
with: | |
publish: true | |
commitish: main | |
- name: Create semver outputs | |
uses: actions/github-script@v7 | |
id: semver | |
with: | |
script: | | |
const matched = "${{ env.VERSION }}".match(/(((\d+)\.\d+).\d+)/) | |
core.setOutput('major', matched[3]) | |
core.setOutput('minor', matched[2]) | |
core.setOutput('patch', matched[1]) | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.VERSION }} | |
- name: Update major tag | |
if: steps.semver.outputs.major != '0' | |
run: | | |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.semver.outputs.major }}" | |
- name: Update minor tag | |
if: steps.semver.outputs.minor != '0.0' | |
run: | | |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.semver.outputs.minor }}" | |
- name: Execute dotnet pack | |
run: | | |
dotnet pack ./VContainerAnalyzer/VContainerAnalyzer.csproj \ | |
-c Release \ | |
-p:Version="${VERSION}" \ | |
-p:PackageVersion="${VERSION}" \ | |
-o . | |
- name: Push to NuGet | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: | | |
dotnet nuget push "VContainerAnalyzer.${VERSION}.nupkg" \ | |
-s https://api.nuget.org/v3/index.json \ | |
-k "${NUGET_API_KEY}" | |
- name: Export unitypackage | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
with: | |
projectPath: ./VContainerAnalyzer.Unity | |
targetPlatform: StandaloneLinux64 | |
buildMethod: Editor.PackageExporter.Export | |
- name: Upload unitypackage | |
run: | | |
gh release upload "${VERSION}" "VContainerAnalyzer.Unity/VContainerAnalyzer.unitypackage" |