Prep Release Action
ActionsAbout
Tags
(2)This action allows you to automate release steps eg bump version, compile code, bundle deps and optionally push/sync those changes back to a source repo that you've fetched with @actions/checkout. It may work with repos fetched in a different way but that use case is not tested or supported so YMMV.
All inputs are optional however if you are NOT triggering this action on a release then you will need to set version.
| Name | Description | Default | Example |
|---|---|---|---|
version |
The version of the thing to be released. Use a semver-valid string or dev to auto-resolve one. |
${{ github.event.release.tag_name }} |
v3.14.0 |
bundle-dependencies |
A toggle to autoset bundleDependencies in package.json. |
false |
true |
commands |
A list of commands to run to prepare the release. | [] |
version-injector --help |
meta |
A list of path=value strings to merge into the package.json |
null |
dist=thing |
root |
The location of the code being prepared for release. | ${{ github.workspace }} |
/path/to/my/project |
bun-version |
An optional Bun version override for this action run. | action repo .bun-version |
1.3.4 |
sync |
A toggle to enable/disable code syncing. | true |
false |
sync-branch |
The target branch to use when syncing changes back to the repo. | ${{ github.event.release.target_commitish || github.event.pull_request.head.ref || github.ref_name }} |
main |
sync-email |
The email to use when syncing changes back to the repo. | 41898282+github-actions[bot]@users.noreply.github.com |
riker@starfleet.gov |
sync-verified |
A toggle to commit synced changes via GitHub GraphQL createCommitOnBranch for GitHub-verified commits. | false |
true |
sync-message |
The commit message to use when syncing changes back to the repo. | release %s generated by @tanaabased/prepare-release-action |
RELEASE %s |
sync-tags |
A list of other tags to sync back to the repo. | [] |
v2 |
sync-token |
A Personal Access Token to use for git sync ops. |
${{ github.token }} |
${{ secrets.MY_PAT }} |
sync-username |
The username to use when syncing changes back to the repo. | github-actions[bot] |
w.t.riker |
update-files |
The files to operate on with update-files-meta and update-files-header. | [] |
CHANGELOG.md |
update-files-header |
A header to prepend to update-files after they've been operated on. | [] |
{{ ## NEW VERSION }} |
update-files-meta |
The find/replace metadata to be used when updating update-files. | [] |
NEW_VERSION=${{ github.event.release.tag_name }} |
version-match |
A regex to help find the latest tag. Only used when version=dev. |
v[0-9].* |
[1-2].* |
Note that sync must be set to true for the other sync-* options to do anything. Also note that in sync-message you can use %s as a placeholder for the version.
When version=dev, this action preserves the semver-valid git describe --tags --always --abbrev=1 --match=<version-match> result when matching tags exist.
If no matching tag exists and that describe output is not semver-valid, it falls back to v${package.json.version}, then v0.0.0-unreleased.<short-sha>.
The resolved value is exported as PREPARE_RELEASE_VERSION for the commands block and later workflow steps, and is also exposed as the resolved-version action output.
| Name | Description |
|---|---|
resolved-version |
The semver-valid version resolved for the current action run. |
When sync-verified=true, this action creates the sync commit with GitHub GraphQL createCommitOnBranch (instead of local git commit) and then pushes tags as usual.
In this mode, sync-username and sync-email still configure local git but do not control the API commit identity.
Also note that sync-verified does not support syncing symlink file changes.
Also note that sync-username and sync-email are simply for git config purposes and DO NOT map to a GitHub user. If you want to do remote git ops as a particular user then use sync-token.
Also also note that bundle-dependencies runs after sync eg it will not push changes to bundleDependencies in your package.json back to your repo. It is intended to be used for packaging dependencies when publishing to an npm compatible package registry eg npm.pkg.github.com.
Also note that while update-files-meta is expressed as KEY=VALUE it must be wrapped with double brackets like {{ KEY }} in the relevant update-files for it to be properly tokenized/replaced. See our CHANGELOG.md for an example using the below inputs:
update-files: CHANGELOG.md
update-files-header: |
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})
update-files-meta: |
UNRELEASED_DATE=May 4, 3000
UNRELEASED_LINK=${{ github.repositoryUrl }}
UNRELEASED_VERSION=v${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt}}-build.${{ github.sha }}You can use our version-injector helper in commands if you want to inject/replace/prepend additional version information into any files.
Use --style json to update additional JSON manifests that already contain a top-level version key.
This is the supported way to bump extra JSON files without adding more action inputs.
Usage: [VERSION_INJECTOR=...] version-injector <file> --style <js|sh|ps1|json> --version <value> [options]
Inject or update version information in a JavaScript, shell, PowerShell, or JSON file.
Options:
--check exits non-zero when the file is not already up to date.
--dry-run reports the planned change without writing the file.
--insert <position> inserts a new assignment with after-shebang, top, or bottom (not supported for json).
--name <var> sets the variable name to update [default: SCRIPT_VERSION] (not used for json).
--style <js|sh|ps1|json>
controls how the assignment line or version field is matched and rendered.
--version <value> sets the version string to write into the file.
--debug shows debug output [default: off]
-h, --help shows this help output.
--version shows the CLI version.
When --style json is used, version-injector semver-cleans the supplied version first, so a value like v1.2.3 is written as 1.2.3.
If you leave sync=true and rely on the default sync-token, the workflow job needs write access to repository contents:
permissions:
contents: writeUse a PAT in sync-token when branch or tag protection prevents ${{ github.token }} from pushing to sync-branch or sync-tags.
sync-verified=true still needs permission to push tags even though the branch commit is created through GitHub GraphQL.
- If your project is a shallow clone (as is the default for
@actions/checkout) we will--unshallowit to a full clone in order to sync changes. - If you have branch or tag protection turned on you will need to make sure your rules allow the
sync-tokenuser to both write to thesync-branchandsync-tagsand to allow a--forcealteration of the repos tags.
permissions:
contents: write
steps:
- name: Prepare Release
uses: tanaabased/prepare-release-action@v1GitHub Action javascript action example:
- name: Prepare Release
uses: tanaabased/prepare-release-action@v1
with:
commands: |
bun run build
version-injector dist/index.js --style js --version "${{ github.ref_name }}"
version-injector dist/version-injector.js --style js --version "${{ github.ref_name }}"
sync-tags: v3Development build example with version=dev:
- name: Prepare Release
id: prepare-release
uses: tanaabased/prepare-release-action@v1
with:
version: dev
sync: false
commands: |
bun run build
version-injector dist/bootbox.sh --style sh --version "$PREPARE_RELEASE_VERSION"
- name: Show resolved version
run: echo "${{ steps.prepare-release.outputs.resolved-version }}"Additional JSON manifest example:
- name: Prepare Release
uses: tanaabased/prepare-release-action@v1
with:
version: dev
sync: false
commands: |
version-injector config/release.json --style json --version "$PREPARE_RELEASE_VERSION"Everything, everywhere, all at once:
- name: Prepare Release
uses: tanaabased/prepare-release-action@v1
with:
version: v3.1.4-riker.1
bundle-dependencies: true
commands: |
touch riker
bun run build
meta: |
jazzman=William T. Riker
bosmang=Picard
sync: true
sync-branch: kirk-epsilon
sync-email: riker@hotmale.com
sync-message: 'Execute evasive manuveur pattern Riker %s'
sync-tags: |
v1
riker1
number2
sync-token: ${{ secrets.MY_PAT }}
sync-username: w.t.riker
sync-verified: true
update-files: CHANGELOG.md
update-files-header: |
## {{ UNRELEASED_VERSION }} - [{{ UNRELEASED_DATE }}]({{ UNRELEASED_LINK }})
update-files-meta: |
UNRELEASED_DATE=May 4, 3000
UNRELEASED_LINK=${{ github.repositoryUrl }}
UNRELEASED_VERSION=v${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt}}-build.${{ github.sha }}
version-match: 'v[0-2].*'bun install --frozen-lockfile --ignore-scripts
bun run lint
bun run format:check
bun run test
bun run buildWe try to log all changes big and small in both THE CHANGELOG and the release notes.
Create a release and publish to GitHub Actions Marketplace
Made with contrib.rocks.
Prep Release Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.