GitHub Actions for Unity.
Details
Automate Unity Package Releases Using GitHub Actions
This action automates the following tasks:
- Updates the version in the Package manifest
- Generates a release
- Creates tags
By starting commit messages with keywords like feat or fix, they will be automatically included in the release notes.
| Type | Description | 
|---|---|
| feat: | Addition of a new feature | 
| fix: | Bug fixes | 
| docs: | Documentation updates or corrections | 
| style: | Code style adjustments (e.g., removing whitespaces) | 
| refactor: | Code changes that neither fix a bug nor add a feature | 
| perf: | Changes made to improve performance | 
If branch or tag protection is enabled, a permission error will occur by default. To bypass this, you can configure GitHub Apps to allow bypassing those protection rules.
- Create a GitHub App
- Install the app and configure it for the target repository
- Set BOT_APP_IDandBOT_PRIVATE_KEYin the repository's Secrets
- Update the protection rules to allow the GitHub App to bypass them
For detailed configuration instructions, please refer to GitHubApp.md.
Enable the Read and write permissions setting under Settings > Actions > General > Workflow permissions.
graph LR
    validate-branch --> update-packagejson
    update-packagejson --> merge-and-push
    merge-and-push --> release-notes
    release-notes --> create-release
    create-release --> clean-branch
    Navigate to the Actions tab and trigger the manual release by selecting Run workflow.
| Option | Description | Default | Example | 
|---|---|---|---|
| tag | Git tag you want to create | 1.0.0 | |
| clean-branch | Delete the branch? All branches except the default branch will be deleted. | false | |
| fast-forward | Allow fast-forward merge | false | |
| include-default-branch | Include the default branch in the workflow behavior | false | |
| dry-run | Simulate the merge without committing or pushing changes | false | |
| draft-release | truefor Draft release,falsefor Non-draft release | false | 
- Create a branch (e.g., release)
- Prepare the release in this branch
- Trigger the manual release via Run workflow
- Copy the code from .github/workflows/build-release_merge.yaml and create a YAML file in your project’s .github/workflows folder.
- Update the file-pathinupdate-packagejsonto fit your project structure.
- If branch protection rules are not used, remove any references to secrets.BOT_APP_IDandsecrets.BOT_PRIVATE_KEY.
- If permission errors occur while running, configure permissions.
graph LR
    extract-tag --> update-packagejson
    update-packagejson --> release-notes
    release-notes --> create-release
    Create a pull request from a prepared branch to the default branch with the release title as the tag name. Once the pull request is merged, the release will be created automatically.
After merging, the release will be created automatically.
A release will be triggered when the following conditions are met:
- The pull request title contains a version number (e.g., 1.0.0)
- The base branch is the default branch
- Create a branch (e.g., release)
- Prepare the release in this branch
- Create a pull request to merge this branch into the default branch. Use the version number as the pull request title.
- Merge the pull request.
- The release will be generated automatically.
- Copy the code from .github/workflows/build-release_pull-request.yaml and create a YAML file in your project’s .github/workflows folder.
- Update the file-pathinupdate-packagejsonto match your project’s file structure.
- If branch protection rules are not used, remove any references to secrets.BOT_APP_IDandsecrets.BOT_PRIVATE_KEY.
- If permission errors occur while running, configure permissions.
Even when using the pull request release method, it is advisable to configure the manual release option as a fallback mechanism. Otherwise, creating new pull requests will be the only way to create releases.
Main Job Descriptions.
.github/workflows/reusable-validate-tag.yaml
This action checks if the tag format is valid and returns outputs.normalized-tag, a normalized version of the tag with only numeric values.
| id | description | default | 
|---|---|---|
| require-validation | trueto disallow old or invalid tags.falseto proceed even if validation fails. | true | 
| validate-semantic-versioning | Specifies whether to validate the tag format using Semantic Versioning. | true | 
| tag | The tag to validate (e.g., 1.0.0). | 
| id | description | 
|---|---|
| normalized-tag | Normalized tag (e.g., tag without the vprefix). | 
| tag | Same as the input tag. | 
| validated | Indicates whether the tag passed validation. | 
.github/workflows/reusable-update-packagejson.yaml
This action updates the version in package.json and commits the changes.
| id | description | default | 
|---|---|---|
| file-path | Path to the package.jsonfile to update. You can provide multiline paths. Onlypackage.jsonfiles are supported. | |
| tag | The Git tag to assign (e.g., 1.0.0). | |
| dry-run | trueto simulate the update and commit without actual changes being pushed. | |
| require-validation | truerequires tag validation to pass,falseallows proceeding even if it fails. | true | 
| ref | The branch or tag to check out before updating. | |
| commit-message-format | Template for the commit message when updating package.json. Example:Update package.json to {v}. | Update package.json to {v} | 
For branch or tag protection:
| id | description | 
|---|---|
| BOT_APP_ID | Specify the application ID | 
| BOT_PRIVATE_KEY | Set the private key for the app | 
| id | description | 
|---|---|
| normalized-tag | Normalized tag (tag without the vprefix). | 
| sha | Git commit SHA after the package.jsonupdate. | 
| changed | Indicates if the Git branch was modified or created. | 
.github/workflows/reusable-merge-and-push.yaml
This action merges branches and pushes the changes.
| id | description | default | 
|---|---|---|
| target-branch | The target branch from the repository to merge. | |
| push-branch | The branch to push the changes into. | |
| commit-id | Commit ID for creating a release and tag. | |
| dry-run | Enables dry-run mode (simulate without committing). | false | 
| fast-forward | Allows a fast-forward merge. | false | 
For branch or tag protection:
| id | description | 
|---|---|
| BOT_APP_ID | Specify the application ID | 
| BOT_PRIVATE_KEY | Set the private key for the app | 
| id | description | 
|---|---|
| sha | Git commit SHA after the merge. | 
| merged | Indicates if the branches were successfully merged. | 
.github/workflows/reusable-release-notes.yaml
This action generates release notes based on commit messages. Messages beginning with fix: or feat: will be included in the release notes.
| id | description | default | 
|---|---|---|
| from-tag | The starting tag (default: first commit if unset). | |
| to-tag | The ending tag (default: latest commit if unset). | |
| commit-message-format | Format for commit messages (see https://git-scm.com/docs/pretty-formats for details). | - %s (%h) | 
| commit-id | Commit ID for release and tag. | |
| derive-from-tag | trueto auto-determinefrom-tagusing previous tags;falseto configure manually. | true | 
| id | description | 
|---|---|
| notes | The generated release notes. | 
.github/workflows/reusable-create-release.yaml
This action creates a release and optionally adds a tag.
| id | description | default | 
|---|---|---|
| commit-id | Commit ID for creating the release and tag. | |
| dry-run | trueto perform a dry run (does not create the release). | |
| require-validation | trueenforces validation;falseskips validation and proceeds. | true | 
| wait-before-delete | The wait time (in seconds) before deleting temporary branches. | 25 | 
| tag | The Git tag to create (e.g., 1.0.0). | |
| release-format | Template for the release title. E.g., Ver.{0}will title the release asVer.1.0.0.{0}omits prefixes. | Ver.{0} | 
| release-note | Custom release notes to include. | |
| draft-release | truefor a draft release;falsefor a final release. | false | 
For branch or tag protection:
| id | description | 
|---|---|
| BOT_APP_ID | Specify the application ID | 
| BOT_PRIVATE_KEY | Set the private key for the app | 
This repository served as a reference or inspiration for the workflows and configurations described above.





