Skip to content

Commit cefcef4

Browse files
ARCH-1911 - Transfer to Infra-Purple (#43)
* +semver:breaking ARCH-1911 - Transfer to Infra-Purple - Remove deprecated create-ref input & associated github-token input - Update CODEOWNERS - Add tests to build-and-review-pr.yml * ARCH-1919 - Adding tests * ARCH-1919 - Handle fork scenarios in test job
1 parent 8ddd14b commit cefcef4

15 files changed

Lines changed: 958 additions & 15244 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @im-open/swat
1+
* @im-open/infra-purple

.github/workflows/build-and-review-pr.yml

Lines changed: 675 additions & 10 deletions
Large diffs are not rendered by default.

.github/workflows/increment-version-on-merge.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ on:
2929
# if this action should be incremented and if new tags should be pushed to the repo based
3030
# on the same criteria used in the build-and-review-pr.yml workflow.
3131

32+
33+
# ------------------------------------------------------------------------------------
34+
# NOTE: This repo duplicates the reusable increment workflow in im-open/.github that
35+
# the rest of the actions use. If changes are needed in this workflow they
36+
# should also be made in im-open/.github. This workflow is duplicated because
37+
# it uses the local copy of itself in the workflow which allows us to test the
38+
# increment build with git-version-lite changes before we merge those changes.
39+
# ------------------------------------------------------------------------------------
40+
3241
jobs:
3342
increment-version:
3443
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
2-
/.vscode/launch.json
2+
/.vscode/launch.json
3+
/pull-request.json
4+
/secrets.txt

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ This template can be used to calculate a release or pre-release version.
88
- [Pre-requisites](#pre-requisites)
99
- [Release vs Pre-release](#release-vs-pre-release)
1010
- [Incrementing Strategy](#incrementing-strategy)
11-
- [Creating a Ref](#creating-a-ref)
1211
- [Inputs](#inputs)
1312
- [Outputs](#outputs)
13+
- [Breaking Changes](#breaking-changes)
14+
- [v2 to v3](#v2-to-v3)
1415
- [Usage Examples](#usage-examples)
1516
- [Contributing](#contributing)
1617
- [Incrementing the Version](#incrementing-the-version)
1718
- [Source Code Changes](#source-code-changes)
1819
- [Recompiling Manually](#recompiling-manually)
1920
- [Updating the README.md](#updating-the-readmemd)
21+
- [Tests](#tests)
2022
- [Code of Conduct](#code-of-conduct)
2123
- [License](#license)
2224

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

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

58-
## Creating a Ref
59-
60-
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.
61-
6260
## Inputs
6361

6462
| Parameter | Is Required | Default | Description |
@@ -67,8 +65,6 @@ The action has a `create-ref` flag and when set to true it uses the GitHub rest
6765
| `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. |
6866
| `calculate-prerelease-version` | false | `false` | Flag indicating whether to calculate a pre-release version rather than a release version. Accepts: `true\|false`. |
6967
| `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. |
70-
| `create-ref` | false | `false` | Flag indicating whether the action should [create a ref] (a release and tag) on the repository. Accepted values: `true\|false`. |
71-
| `github-token` | Required when<br/>`create-ref: true` | N/A | Token with permissions to create a ref on the repository. |
7268
| `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`. |
7369

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

86+
## Breaking Changes
87+
88+
### v2 to v3
89+
90+
- The `create-ref` input was removed
91+
- This input has been deprecated for a while. We recommend replacing this functionality with the `[im-open/create-release]` action.
92+
- The `github-token` input was removed
93+
- This was only needed to create a ref on the repository so it is no longer needed.
94+
- The `NEXT_VERSION_SHA` output was removed
95+
- Workflows can use the value that git-version-lite outputted directly.
96+
- For `pull_request` workflow triggers the value was `github.event.pull_request.head.sha`.
97+
- For all other workflow triggers the value was `github.sha`
98+
9099
## Usage Examples
91100

92101
```yml
@@ -107,16 +116,14 @@ jobs:
107116

108117
- id: get-version
109118
# You may also reference just the major version.
110-
uses: im-open/git-version-lite@v2.3.2
119+
uses: im-open/git-version-lite@v3.0.0
111120
with:
112121
calculate-prerelease-version: true
113122
branch-name: ${{ github.head_ref }} # github.head_ref works when the trigger is pull_request
114123
tag-prefix: v # Prepend a v to any calculated release/pre-release version
115124
fallback-to-no-prefix-search: true # Set to true can be helpful when starting to add tag prefixes
116125
default-release-type: major # If no tags are found, default to doing a major increment
117-
create-ref: true # Will create a release/tag on the repo
118-
github-token: ${{ secrets.GITHUB_TOKEN }} # Required when creating a ref
119-
126+
120127
- run: |
121128
echo "The next version is ${{ env.NEXT_VERSION }}"
122129
echo "The next version without the prefix is ${{ steps.get-version.outputs.NEXT_VERSION_NO_PREFIX }}"
@@ -131,6 +138,7 @@ When creating PRs, please review the following guidelines:
131138
- [ ] At least one of the commit messages contains the appropriate `+semver:` keywords listed under [Incrementing the Version] for major and minor increments.
132139
- [ ] The action has been recompiled. See [Recompiling Manually] for details.
133140
- [ ] The README.md has been updated with the latest version of the action. See [Updating the README.md] for details.
141+
- [ ] Any tests in the [build-and-review-pr] workflow are passing
134142

135143
### Incrementing the Version
136144

@@ -165,6 +173,12 @@ npm run build
165173

166174
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.
167175

176+
### Tests
177+
178+
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.
179+
180+
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.
181+
168182
## Code of Conduct
169183

170184
This project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/main/CODE_OF_CONDUCT.md).
@@ -183,4 +197,3 @@ Copyright &copy; 2023, Extend Health, LLC. Code released under the [MIT license]
183197
[increment-version-on-merge]: ./.github/workflows/increment-version-on-merge.yml
184198
[esbuild]: https://esbuild.github.io/getting-started/#bundling-for-node
185199
[git-version-lite]: https://github.com/im-open/git-version-lite
186-
[create a ref]: https://docs.github.com/en/rest/reference/git#create-a-reference

action.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: An action to calculate the next tag for the repository based on com
55
inputs:
66
calculate-prerelease-version:
77
description: 'Flag indicating whether to calculate a pre-release version rather than a release version. Accepts: true|false.'
8-
required: true
8+
required: false
99
default: 'false'
1010

1111
branch-name:
@@ -14,28 +14,18 @@ inputs:
1414

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

2020
fallback-to-no-prefix-search:
2121
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.'
22-
required: true
22+
required: false
2323
default: 'true'
2424

2525
default-release-type:
2626
description: 'The default release type that should be used when no tags are detected. Defaults to major. Accepted values: major|minor|patch'
27-
required: true
28-
default: 'major'
29-
30-
# Deprecated input. Instead create a release with the im-open/create-release action
31-
create-ref:
32-
description: 'Flag indicating whether the action should create a ref (a release and tag) on the repository. Accepted values: true|false'
33-
required: true
34-
default: 'false'
35-
36-
github-token:
37-
description: Token with permissions to push a ref to the repository
3827
required: false
28+
default: 'major'
3929

4030
outputs:
4131
NEXT_VERSION:
@@ -56,9 +46,6 @@ outputs:
5646
NEXT_MAJOR_VERSION_NO_PREFIX:
5747
description: 'The next major version without the tag prefix.'
5848

59-
NEXT_VERSION_SHA:
60-
description: 'The SHA of the next version as an environment variable.'
61-
6249
PRIOR_VERSION:
6350
description: 'The previous major.minor.patch version.'
6451

0 commit comments

Comments
 (0)