Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARCH-1911 - Transfer to Infra-Purple #43

Merged
merged 3 commits into from
Oct 16, 2023
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @im-open/swat
* @im-open/infra-purple
685 changes: 675 additions & 10 deletions .github/workflows/build-and-review-pr.yml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .github/workflows/increment-version-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ on:
# if this action should be incremented and if new tags should be pushed to the repo based
# on the same criteria used in the build-and-review-pr.yml workflow.


# ------------------------------------------------------------------------------------
# NOTE: This repo duplicates the reusable increment workflow in im-open/.github that
# the rest of the actions use. If changes are needed in this workflow they
# should also be made in im-open/.github. This workflow is duplicated because
# it uses the local copy of itself in the workflow which allows us to test the
# increment build with git-version-lite changes before we merge those changes.
# ------------------------------------------------------------------------------------

jobs:
increment-version:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
/.vscode/launch.json
/.vscode/launch.json
/pull-request.json
/secrets.txt
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ This template can be used to calculate a release or pre-release version.
- [Pre-requisites](#pre-requisites)
- [Release vs Pre-release](#release-vs-pre-release)
- [Incrementing Strategy](#incrementing-strategy)
- [Creating a Ref](#creating-a-ref)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [Breaking Changes](#breaking-changes)
- [v2 to v3](#v2-to-v3)
- [Usage Examples](#usage-examples)
- [Contributing](#contributing)
- [Incrementing the Version](#incrementing-the-version)
- [Source Code Changes](#source-code-changes)
- [Recompiling Manually](#recompiling-manually)
- [Updating the README.md](#updating-the-readmemd)
- [Tests](#tests)
- [Code of Conduct](#code-of-conduct)
- [License](#license)

Expand Down Expand Up @@ -55,10 +57,6 @@ The action will increment the minor version if it identifies any of the followin

If none of the previous patterns match, the action will increment the patch version.

## Creating a Ref

The action has a `create-ref` flag and when set to true it uses the GitHub rest API to [create a ref]. This API call results in a release and a tag being created. This may be desirable in some workflows where you are incrementing on merge but may not work well for others like a CI build where you want to hold off pushing the ref until some steps have completed.

## Inputs

| Parameter | Is Required | Default | Description |
Expand All @@ -67,8 +65,6 @@ The action has a `create-ref` flag and when set to true it uses the GitHub rest
| `fallback-to-no-prefix-search` | false | `true` | Flag indicating whether it should fallback to a prefix-less search if no tags are found with the current prefix. Helpful when starting to use prefixes with tags. Accepted values: true\|false. |
| `calculate-prerelease-version` | false | `false` | Flag indicating whether to calculate a pre-release version rather than a release version. Accepts: `true\|false`. |
| `branch-name` | Required when<br/>`calculate-prerelease-version: true` | N/A | The name of the branch the next pre-release version is being generated for. Required when calculating the pre-release version. |
| `create-ref` | false | `false` | Flag indicating whether the action should [create a ref] (a release and tag) on the repository. Accepted values: `true\|false`. |
| `github-token` | Required when<br/>`create-ref: true` | N/A | Token with permissions to create a ref on the repository. |
| `default-release-type` | false | `major` | The default release type that should be used when no tags are detected. Defaults to major. Accepted values: `major\|minor\|patch`. |

## Outputs
Expand All @@ -87,6 +83,19 @@ Each of the outputs are available as environment variables and as action outputs
| `PRIOR_VERSION` | The previous `major.minor.patch` version |
| `PRIOR_VERSION_NO_PREFIX` | The previous `major.minor.patch` version without the tag prefix |

## Breaking Changes

### v2 to v3

- The `create-ref` input was removed
- This input has been deprecated for a while. We recommend replacing this functionality with the `[im-open/create-release]` action.
- The `github-token` input was removed
- This was only needed to create a ref on the repository so it is no longer needed.
- The `NEXT_VERSION_SHA` output was removed
- Workflows can use the value that git-version-lite outputted directly.
- For `pull_request` workflow triggers the value was `github.event.pull_request.head.sha`.
- For all other workflow triggers the value was `github.sha`

## Usage Examples

```yml
Expand All @@ -107,16 +116,14 @@ jobs:

- id: get-version
# You may also reference just the major version.
uses: im-open/git-version-lite@v2.3.2
uses: im-open/git-version-lite@v3.0.0
with:
calculate-prerelease-version: true
branch-name: ${{ github.head_ref }} # github.head_ref works when the trigger is pull_request
tag-prefix: v # Prepend a v to any calculated release/pre-release version
fallback-to-no-prefix-search: true # Set to true can be helpful when starting to add tag prefixes
default-release-type: major # If no tags are found, default to doing a major increment
create-ref: true # Will create a release/tag on the repo
github-token: ${{ secrets.GITHUB_TOKEN }} # Required when creating a ref


- run: |
echo "The next version is ${{ env.NEXT_VERSION }}"
echo "The next version without the prefix is ${{ steps.get-version.outputs.NEXT_VERSION_NO_PREFIX }}"
Expand All @@ -131,6 +138,7 @@ When creating PRs, please review the following guidelines:
- [ ] At least one of the commit messages contains the appropriate `+semver:` keywords listed under [Incrementing the Version] for major and minor increments.
- [ ] The action has been recompiled. See [Recompiling Manually] for details.
- [ ] The README.md has been updated with the latest version of the action. See [Updating the README.md] for details.
- [ ] Any tests in the [build-and-review-pr] workflow are passing

### Incrementing the Version

Expand Down Expand Up @@ -165,6 +173,12 @@ npm run build

If changes are made to the action's [source code], the [usage examples] section of this file should be updated with the next version of the action. Each instance of this action should be updated. This helps users know what the latest tag is without having to navigate to the Tags page of the repository. See [Incrementing the Version] for details on how to determine what the next version will be or consult the first workflow run for the PR which will also calculate the next version.

### Tests

The [build-and-review-pr] workflow includes tests which are linked to a status check. That status check needs to succeed before a PR is merged to the default branch. When a PR comes from a branch, the workflow has access to secrets which are required to run the tests successfully.

When a PR comes from a fork, the workflow cannot access any secrets, so the tests won't have the necessary permissions to run. When a PR comes from a fork, the changes should be reviewed, then merged into an intermediate branch by repository owners so tests can be run against the PR changes. Once the tests have passed, changes can be merged into the default branch.

## Code of Conduct

This project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/main/CODE_OF_CONDUCT.md).
Expand All @@ -183,4 +197,3 @@ Copyright &copy; 2023, Extend Health, LLC. Code released under the [MIT license]
[increment-version-on-merge]: ./.github/workflows/increment-version-on-merge.yml
[esbuild]: https://esbuild.github.io/getting-started/#bundling-for-node
[git-version-lite]: https://github.com/im-open/git-version-lite
[create a ref]: https://docs.github.com/en/rest/reference/git#create-a-reference
21 changes: 4 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: An action to calculate the next tag for the repository based on com
inputs:
calculate-prerelease-version:
description: 'Flag indicating whether to calculate a pre-release version rather than a release version. Accepts: true|false.'
required: true
required: false
default: 'false'

branch-name:
Expand All @@ -14,28 +14,18 @@ inputs:

tag-prefix:
description: 'By default the action strips the prefixes off, but any value provided here will be prepended to the next calculated version.'
required: true
required: false
default: 'v'

fallback-to-no-prefix-search:
description: 'Flag indicating whether it should fallback to a prefix-less search if no tags are found with the current prefix. Helpful when starting to use prefixes with tags. Accepted values: true|false.'
required: true
required: false
default: 'true'

default-release-type:
description: 'The default release type that should be used when no tags are detected. Defaults to major. Accepted values: major|minor|patch'
required: true
default: 'major'

# Deprecated input. Instead create a release with the im-open/create-release action
create-ref:
description: 'Flag indicating whether the action should create a ref (a release and tag) on the repository. Accepted values: true|false'
required: true
default: 'false'

github-token:
description: Token with permissions to push a ref to the repository
required: false
default: 'major'

outputs:
NEXT_VERSION:
Expand All @@ -56,9 +46,6 @@ outputs:
NEXT_MAJOR_VERSION_NO_PREFIX:
description: 'The next major version without the tag prefix.'

NEXT_VERSION_SHA:
description: 'The SHA of the next version as an environment variable.'

PRIOR_VERSION:
description: 'The previous major.minor.patch version.'

Expand Down
Loading
Loading