Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ Pin to a version tag instead of `master` if you want fully repeatable workflow r
By default, the action reads commit messages from git history between the previous matching tag and `HEAD`.
Use `fetch-depth: 0` with `actions/checkout` so the runner has enough history and tags to find that range.
If no matching previous tag exists, the action reads all reachable commits.
If the git range cannot be read, the action falls back to the GitHub event payload for compatibility.

| Range | Behavior |
| ------------ | ----------------------------------------------------------------------------- |
| previous-tag | Reads commits from the previous tag matching `commit_tag_pattern` to `HEAD`. |
| base-ref | Reads commits from `commit_base_ref` to `HEAD`. |
| payload | Reads commit messages from the GitHub event payload, matching older behavior. |
| Range | Behavior |
|--------------|------------------------------------------------------------------------------|
| previous-tag | Reads commits from the previous tag matching `commit_tag_pattern` to `HEAD`. |
| base-ref | Reads commits from `commit_base_ref` to `HEAD`. |

For pull request or protected-branch workflows, set an explicit base ref:

Expand Down Expand Up @@ -155,7 +153,7 @@ buildNumber=
```

| Backend | File | Behavior |
| ------------------ | -------------------- | ----------------------------------------------------------------- |
|--------------------|----------------------|-------------------------------------------------------------------|
| version-properties | `version.properties` | Compatibility default. The action writes the version keys file. |
| gradle-properties | `gradle.properties` | The action updates the version keys and preserves unrelated keys. |

Expand Down Expand Up @@ -344,28 +342,27 @@ Enable this field by passing a build number/string/SHA as an input to the action

Pass these in the `with:` block

| Tag | Effect | Example | Default value |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | ------------------------ |
| app_path | App or module path used to scope version storage and optional path filtering. | `app_path: apps/mobile` stores versions in `apps/mobile/version.properties` | '' |
| commit_range | Selects where version bump commit messages come from. Supported values are `previous-tag`, `base-ref`, and `payload`. | `commit_range: base-ref` reads from `commit_base_ref` to `HEAD` | `previous-tag` |
| commit_base_ref | Base ref used when `commit_range` is `base-ref`. If omitted, pull request workflows use `origin/${{ github.base_ref }}` when available. | `commit_base_ref: origin/main` | '' |
| commit_tag_pattern | Tag glob used when `commit_range` is `previous-tag`. Defaults to `${git_tag_prefix}*` when `git_tag_prefix` is set. | `commit_tag_pattern: 'v*'` | `*` |
| version_storage | Selects where version metadata is read from and written to. Supported values are `version-properties` and `gradle-properties`. | `version_storage: gradle-properties` updates `gradle.properties` | `version-properties` |
| git_tag_prefix | Prefix used for the created git tag and the `git_tag` and `new_tag` outputs. | `git_tag_prefix: mobile-v` creates `mobile-v1.2.3` | '' |
| path_filter | When true, only commits touching `app_path` can trigger a bump. Cannot be combined with `commit_range: payload`. | `path_filter: true` | false |
| tag_prefix | Prefix used in the generated release commit message. | `tag_prefix: 'release-'` makes the default commit message `release: release-1.0.0` | `v` |
| skip_ci | Affixes `[skip-ci]` to the end of the commit message, even if you provide a custom message | `skip_ci: false` | true |
| build_number | Sets the build run number in the version | `build_number: ${{ github.run_number }}` generates `1.0.0.5` | '' |
| commit_message | Sets the commit message when a release bump is performed. Can optionally use `{{ version }}` to insert the generated version bump with the tag prefix into the commit message. | `ci: {{ version }} was just released into the wild! :tada: :partying_face:` | `release: {{ version }}` |
| Tag | Effect | Example | Default value |
|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|--------------------------|
| app_path | App or module path used to scope version storage and optional path filtering. | `app_path: apps/mobile` stores versions in `apps/mobile/version.properties` | '' |
| commit_range | Selects where version bump commit messages come from. Supported values are `previous-tag` and `base-ref`. | `commit_range: base-ref` reads from `commit_base_ref` to `HEAD` | `previous-tag` |
| commit_base_ref | Base ref used when `commit_range` is `base-ref`. If omitted, pull request workflows use `origin/${{ github.base_ref }}` when available. | `commit_base_ref: origin/main` | '' |
| commit_tag_pattern | Tag glob used when `commit_range` is `previous-tag`. Defaults to `${git_tag_prefix}*` when `git_tag_prefix` is set. | `commit_tag_pattern: 'v*'` | `*` |
| version_storage | Selects where version metadata is read from and written to. Supported values are `version-properties` and `gradle-properties`. | `version_storage: gradle-properties` updates `gradle.properties` | `version-properties` |
| git_tag_prefix | Prefix used for the created git tag and the `git_tag` output. | `git_tag_prefix: mobile-v` creates `mobile-v1.2.3` | '' |
| path_filter | When true, only commits touching `app_path` can trigger a bump. | `path_filter: true` | false |
| commit_message_version_prefix | Prefix used for the generated version token in release commit messages. | `commit_message_version_prefix: release-` makes the default commit message `release: release-1.0.0` | `v` |
| skip_ci | Affixes `[skip-ci]` to the end of the commit message, even if you provide a custom message | `skip_ci: false` | true |
| build_number | Sets the build run number in the version | `build_number: ${{ github.run_number }}` generates `1.0.0.5` | '' |
| commit_message | Sets the commit message when a release bump is performed. Can optionally use `{{ version }}` to insert the generated version token into the commit message. | `ci: {{ version }} was just released into the wild! :tada: :partying_face:` | `release: {{ version }}` |

## Outputs

| Name | Description | Example |
| -------------- | ----------------------------------------------------- | ---------- |
|----------------|-------------------------------------------------------|------------|
| git_tag | The newly created git tag | `1.0.0` |
| version_name | The generated Android version name | `1.0.0.5` |
| version_code | The generated Android version code | `10000` |
| new_tag | Compatibility alias for `git_tag` | `1.0.0` |
| release_action | The release action performed: `released` or `skipped` | `released` |

## Q&A
Expand All @@ -388,4 +385,3 @@ The action also outputs a tag that you can use in later stages of the workflow l
```

Make sure you also assign the bump version step its own id (in this case it was already set to `id: bump_version`)
Older workflows can keep using `new_tag`; it is preserved as a compatibility alias for `git_tag`.
10 changes: 4 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inputs:
description: 'App or module path used to scope version storage and optional path filtering'
commit_range:
required: false
description: 'Commit range source for version bumping: previous-tag, base-ref, or payload'
description: 'Commit range source for version bumping: previous-tag or base-ref'
default: 'previous-tag'
commit_base_ref:
required: false
Expand All @@ -28,14 +28,14 @@ inputs:
default: 'version-properties'
git_tag_prefix:
required: false
description: 'Prefix to add to the created git tag and git_tag/new_tag outputs'
description: 'Prefix to add to the created git tag and git_tag output'
path_filter:
required: false
description: 'Only bump when git commits in the selected range touch app_path'
default: 'false'
tag_prefix:
commit_message_version_prefix:
required: false
description: 'Prefix to add to the generated release commit message'
description: 'Prefix to add to the generated version token in release commit messages'
skip_ci:
required: false
description: 'Affix [skip-ci] so that a cyclical ci loop does not happen'
Expand All @@ -47,8 +47,6 @@ inputs:
required: false
description: 'Build number to generated from ci to show as part of the version'
outputs:
new_tag:
description: 'Compatibility alias for git_tag'
git_tag:
description: 'The newly created git tag'
version_name:
Expand Down
16 changes: 3 additions & 13 deletions dist/index.js

Large diffs are not rendered by default.

39 changes: 6 additions & 33 deletions e2e/action.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ describe('packaged action with local git repositories', () => {
expect(gitInRemote(fixture, 'log', '-1', '--format=%s', 'main')).toBe(
'release: v0.0.1 [skip-ci]',
);
expect(readOutput(fixture)).toBe('new_tag=0.0.1');
expect(readOutput(fixture)).toBe('git_tag=0.0.1');
expect(readOutputs(fixture)).toEqual({
new_tag: '0.0.1',
git_tag: '0.0.1',
version_name: '0.0.1',
version_code: '1',
Expand Down Expand Up @@ -138,7 +137,7 @@ describe('packaged action with local git repositories', () => {
inputs: {
commit_range: 'base-ref',
commit_base_ref: 'origin/main',
tag_prefix: 'release-',
commit_message_version_prefix: 'release-',
skip_ci: 'false',
build_number: '42',
commit_message: 'publish {{version}}',
Expand All @@ -159,9 +158,8 @@ describe('packaged action with local git repositories', () => {
expect(
gitInRemote(fixture, 'show', `${fixture.branch}:version.properties`),
).toContain('buildNumber=42');
expect(readOutput(fixture)).toBe('new_tag=1.3.0.42');
expect(readOutput(fixture)).toBe('git_tag=1.3.0.42');
expect(readOutputs(fixture)).toEqual({
new_tag: '1.3.0.42',
git_tag: '1.3.0.42',
version_name: '1.3.0.42',
version_code: '10300',
Expand All @@ -172,14 +170,10 @@ describe('packaged action with local git repositories', () => {
);
});

it('uses squash-style git history instead of payload commit details', () => {
it('uses squash-style git history', () => {
const fixture = run({
version: '1.2.3',
commits: ['feat: squash login branch (#42)'],
eventCommits: [
{ id: 'fixture-1', message: 'fix: payload detail one' },
{ id: 'fixture-2', message: 'fix: payload detail two' },
],
});

expect(fixture.result.status).toBe(0);
Expand Down Expand Up @@ -255,7 +249,6 @@ describe('packaged action with local git repositories', () => {
gitInRemote(fixture, 'rev-parse', 'refs/heads/main'),
);
expect(readOutputs(fixture)).toMatchObject({
new_tag: 'mobile-v1.2.4',
git_tag: 'mobile-v1.2.4',
version_name: '1.2.4',
release_action: 'released',
Expand Down Expand Up @@ -307,7 +300,6 @@ describe('packaged action with local git repositories', () => {
gitInRemote(fixture, 'rev-parse', 'refs/heads/main'),
);
expect(readOutputs(fixture)).toMatchObject({
new_tag: 'admin-v9.9.0',
git_tag: 'admin-v9.9.0',
version_name: '9.9.0',
release_action: 'released',
Expand Down Expand Up @@ -350,14 +342,13 @@ describe('packaged action with local git repositories', () => {
);
expect(gitInRemote(fixture, 'tag', '--list', 'mobile-v1.2.4')).toBe('');
expect(readOutputs(fixture)).toMatchObject({
new_tag: 'mobile-v1.2.3',
git_tag: 'mobile-v1.2.3',
version_name: '1.2.3',
release_action: 'skipped',
});
});

it('rejects payload commit range when path filtering is enabled', () => {
it('rejects payload commit range', () => {
const fixture = run({
appVersions: {
'apps/mobile': '1.2.3',
Expand All @@ -371,13 +362,12 @@ describe('packaged action with local git repositories', () => {
inputs: {
app_path: 'apps/mobile',
commit_range: 'payload',
path_filter: 'true',
},
});

expect(fixture.result.status).toBe(1);
expect(`${fixture.result.stdout}${fixture.result.stderr}`).toContain(
'path_filter cannot be used with commit_range payload',
'Invalid commit range "payload"',
);
expect(gitInRemote(fixture, 'tag', '--list', '1.2.4')).toBe('');
});
Expand Down Expand Up @@ -448,29 +438,12 @@ describe('packaged action with local git repositories', () => {
);
});

it('can use commit messages from real GitHub push payload objects (#122)', () => {
const fixture = run({
version: '1.2.3',
commits: ['fix: repair launch'],
inputs: {
commit_range: 'payload',
},
eventCommits: [{ id: 'fixture', message: 'feat: add login' }],
});

expect(fixture.result.status).toBe(0);
expect(gitInRemote(fixture, 'show', 'main:version.properties')).toContain(
'minorVersion=3',
);
});

it('declares the output written by the packaged action', () => {
const action = fs.readFileSync(
path.resolve(__dirname, '../action.yml'),
'utf8',
);

expect(action).toContain(' new_tag:');
expect(action).toContain(' git_tag:');
expect(action).toContain(' version_name:');
expect(action).toContain(' version_code:');
Expand Down
Loading