Skip to content

ARCH-1108 - Standardize the readme and increment version workflow. #2

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

Merged
merged 1 commit into from
Nov 25, 2021
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
37 changes: 6 additions & 31 deletions .github/workflows/increment-version-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,18 @@ jobs:
increment-version:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'

runs-on: [ubuntu-20.04]
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

# See https://github.com/im-open/git-version-lite for more details around how to increment major/minor/patch through commit messages
- name: Increment the version
uses: actions/github-script@v4
uses: im-open/git-version-lite@v2.0.6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const util = require('util');
const exec = util.promisify(require('child_process').exec);

let newTag;
try {
({ stdout: tag } = await exec(`git describe --tags --abbrev=0`));

tag = tag.replace('\n', '').trim();
core.info(`The latest tag is: ${tag}`);
const majorMinorPatch = tag.split('.');
const patch = parseInt(majorMinorPatch[2]) + 1;
newTag = `${majorMinorPatch[0]}.${majorMinorPatch[1]}.${patch}`
core.info(`The new tag is: ${newTag}`);
}
catch (error) {
newTag = 'v1.0.0';
core.info('An error occurred getting the tags for the repo. It most likely does not have any tags to use. Defaulting to v1.0.0.');
core.info(error);
}

core.info(`Pushing tag '${newTag}' to the repository...`)
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${newTag}`,
sha: context.sha
});
create-ref: true
github-token: ${{ secrets.GITHUB_TOKEN }}
default-release-type: major
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ This action is based on [danielpalme/ReportGenerator-GitHub-Action].
[ReportGenerator] converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.

This action does not generate the code coverage reports itself, those must be created by a previous action.

## Index

- [Inputs](#inputs)
- [Usage](#usage)
- [Contributing](#contributing)
- [Recompiling](#recompiling)
- [Incrementing the Version](#incrementing-the-version)
- [Code of Conduct](#code-of-conduct)
- [License](#license)

## Inputs
| Parameter | Is Required | Default Value | Description |
Expand Down Expand Up @@ -37,7 +47,7 @@ This action does not generate the code coverage reports itself, those must be cr
run: dotnet test ${{ env.SOLUTION }} --no-restore --logger trx --configuration Release /property:CollectCoverage=True /property:CoverletOutputFormat=opencover

- name: ReportGenerator
uses: im-open/code-coverage-report-generator@4.8.12
uses: im-open/code-coverage-report-generator@4.8.14
with:
reports: '*/**/coverage.opencover.xml'
targetdir: ${{ env.CODE_COVERAGE_DIR }}'
Expand All @@ -61,15 +71,23 @@ This action does not generate the code coverage reports itself, those must be cr
path: ${{ env.CODE_COVERAGE_DIR }}

- name: Create a PR comment from the summary file
uses: im-open/process-code-coverage-summary@v1.0.0
uses: im-open/process-code-coverage-summary@v2.0.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-file: '${{ env.CODE_COVERAGE_DIR }}/Summary.md'
create-pr-comment: true
create-status-check: false
```

## Recompiling
## Contributing

When creating new PRs please ensure:
1. The action has been recompiled. See the [Recompiling](#recompiling) section below for more details.
2. For major or minor changes, at least one of the commit messages contains the appropriate `+semver:` keywords listed under [Incrementing the Version](#incrementing-the-version).
3. The `README.md` example has been updated with the new version. See [Incrementing the Version](#incrementing-the-version).
4. The action code does not contain sensitive information.

### Recompiling

If changes are made to the action's code in this repository, or its dependencies, you will need to re-compile the action.

Expand All @@ -80,6 +98,17 @@ npm run build

These commands utilize [ncc](https://github.com/vercel/ncc) to bundle the action and its dependencies into a single file located in the `dist` folder.

### Incrementing the Version

This action uses [git-version-lite] to examine commit messages to determine whether to perform a major, minor or patch increment on merge. The following table provides the fragment that should be included in a commit message to active different increment strategies.
| Increment Type | Commit Message Fragment |
| -------------- | ------------------------------------------- |
| major | +semver:breaking |
| major | +semver:major |
| minor | +semver:feature |
| minor | +semver:minor |
| patch | *default increment type, no comment needed* |

## Code of Conduct

This project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/master/CODE_OF_CONDUCT.md).
Expand All @@ -88,6 +117,7 @@ This project has adopted the [im-open's Code of Conduct](https://github.com/im-o

Copyright © 2021, Extend Health, LLC. Code released under the [MIT license](LICENSE).

[git-version-lite]: https://github.com/im-open/git-version-lite
[danielpalme/ReportGenerator-GitHub-Action]: https://github.com/danielpalme/ReportGenerator-GitHub-Action
[ReportGenerator]: https://github.com/danielpalme/ReportGenerator
[Settings]: https://github.com/danielpalme/ReportGenerator/wiki/Settings