Skip to content

Bump DeNA/setup-job-workspace-action from 369dc36d8a855b2a47d90030e9a5ae7a2ae736f8 to cfd2a6af0a6f6f750d803c1c46091c7bf52f62d7 #91

Bump DeNA/setup-job-workspace-action from 369dc36d8a855b2a47d90030e9a5ae7a2ae736f8 to cfd2a6af0a6f6f750d803c1c46091c7bf52f62d7

Bump DeNA/setup-job-workspace-action from 369dc36d8a855b2a47d90030e9a5ae7a2ae736f8 to cfd2a6af0a6f6f750d803c1c46091c7bf52f62d7 #91

Workflow file for this run

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: package.json
GITHUB_BOT_NAME: github-actions[bot]
GITHUB_BOT_EMAIL: github-actions[bot]@users.noreply.github.com
jobs:
paths-filter:
name: Paths Filter for Updating Release
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 }}
update-draft:
name: Update Draft
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch'}}
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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: update-draft
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
VERSION: ${{ needs.update-draft.outputs.tag_name }}
SOURCE_BRANCH: github-actions/update-files/${{ github.run_number }}
steps:
- uses: actions/checkout@v4
- name: Update package.json
run: |
json_content=$(cat "${PACKAGE_JSON_PATH}")
updated_json=$(echo "${json_content}" | jq --arg version "${VERSION}" '.version = $version')
echo "${updated_json}" | jq '.' > "${PACKAGE_JSON_PATH}"
- name: Commit package.json
uses: EndBug/add-and-commit@v9
id: commit-package-json
with:
author_name: ${{ env.GITHUB_BOT_NAME }}
author_email: ${{ env.GITHUB_BOT_EMAIL }}
message: "Update package.json"
add: ${{ env.PACKAGE_JSON_PATH }}
new_branch: ${{ env.SOURCE_BRANCH }}
- name: Update README.md
run: |
cp -f .github/DRAFT_README.md README.md
- name: Commit README.md
uses: EndBug/add-and-commit@v9
id: commit-readme
with:
author_name: ${{ env.GITHUB_BOT_NAME }}
author_email: ${{ env.GITHUB_BOT_EMAIL }}
message: "Update README.md"
add: "README.md"
new_branch: ${{ env.SOURCE_BRANCH }}
- uses: actions/create-github-app-token@v1
id: create-github-app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create pull request and merge
if: ${{ steps.commit-package-json.outputs.committed == 'true' || steps.commit-readme.outputs.committed == 'true'}}
env:
GH_TOKEN: ${{ steps.create-github-app-token.outputs.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: [update-draft, paths-filter]
environment: Release
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.merged && needs.paths-filter.outputs.package_json == 'true' }}
env:
VERSION: ${{ needs.update-draft.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
with:
ref: main
- name: Validate version in package.json
run: |
package_version=$(jq -r '.version' "${PACKAGE_JSON_PATH}")
if [[ "${package_version}" != "${VERSION}" ]]; then
echo "::error::version in package.json (${package_version}) does not match the release draft tag (${VERSION})"
exit 1
fi
- uses: release-drafter/release-drafter@v6
id: release-drafter
with:
publish: true
commitish: main
- name: Get semver
id: get-semver
run: |
read -r major minor patch <<< "$(echo "${VERSION}" | grep -oE '^([0-9]+)\.([0-9]+)\.([0-9]+)' | awk -F '.' '{print $1 " " $2 " " $3}')"
{
echo "major=${major}"
echo "minor=${major}.${minor}"
echo "patch=${major}.${minor}.${patch}"
} >> "${GITHUB_OUTPUT}"
- uses: actions/checkout@v4
with:
ref: ${{ env.VERSION }}
- name: Update major tag
if: steps.get-semver.outputs.major != '0'
run: |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.get-semver.outputs.major }}"
- name: Update minor tag
if: steps.get-semver.outputs.minor != '0.0'
run: |
git push -f origin "refs/tags/${VERSION}:refs/tags/${{ steps.get-semver.outputs.minor }}"
- 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:
targetPlatform: StandaloneLinux64
buildMethod: Editor.PackageExporter.Export
projectPath: Samples~
- name: Upload unitypackage
run: |
gh release upload "${VERSION}" "Samples~/JobSummaryUtility.unitypackage"