Skip to content

Commit

Permalink
+semver:breaking
Browse files Browse the repository at this point in the history
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
  • Loading branch information
danielle-casella-adams committed Sep 22, 2023
1 parent 8ddd14b commit 8f23ac0
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 15,182 deletions.
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
41 changes: 39 additions & 2 deletions .github/workflows/build-and-review-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0

- name: Check for code changes to the action source code
Expand All @@ -55,11 +54,15 @@ jobs:
if: steps.source-code.outputs.HAS_CHANGES == 'true'
id: version
uses: ./
with:
calculate-prerelease-version: false
tag-prefix: v
fallback-to-no-prefix-search: false

- name: The next action version will be - ${{ steps.version.outputs.NEXT_VERSION || 'N/A'}}
if: steps.source-code.outputs.HAS_CHANGES == 'true'
run: echo "The next action version will be - ${{ steps.version.outputs.NEXT_VERSION }}"

build-and-review-pr:
runs-on: ubuntu-latest
needs: [setup]
Expand Down Expand Up @@ -201,3 +204,37 @@ jobs:
.addRaw(instructionsWithLinks)
.write();
core.setFailed(instructions);
# test:
# runs-on: ubuntu-latest

# env:
# PRODUCTION_READY_TAG: 'v1.1.3'
# PRE_RELEASE_TAG: 'v1.0.2'
# DRAFT_RELEASE_TAG: 'v1.0.1'
# NONEXISTENT_RELEASE_TAG: 'v304.973.444'

# steps:
# - uses: actions/checkout@v3

# #--------------------------------------
# # RELEASE IS PRODUCTION READY RELEASE
# #--------------------------------------
# - name: '-------------------------------------------------------------------------------------------------------'
# run: echo ""
# - name: When validating a prod ready release (${{ env.PRODUCTION_READY_TAG}})
# uses: ./
# if: always()
# id: production-release
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# release-tag: ${{ env.PRODUCTION_READY_TAG }}
# fail-for-prerelease: false

# - name: Then the outcome should be success
# if: always()
# run: ./test/assert-values-match.sh --name "step outcome" --expected "success" --actual "${{ steps.production-release.outcome }}"

# - name: And the output should be true
# if: always()
# run: ./test/assert-values-match.sh --name "PRODUCTION_READY" --expected "true" --actual "${{ steps.production-release.outputs.PRODUCTION_READY }}"
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
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ 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)
Expand Down Expand Up @@ -55,10 +56,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 +64,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 +82,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 +115,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 Down
13 changes: 0 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ inputs:
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

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

0 comments on commit 8f23ac0

Please sign in to comment.