Skip to content

Commit 56367fe

Browse files
authored
Merge pull request #2 from im-open/standardize-action
ARCH-1108 - Standardize the readme and increment version workflow.
2 parents f72adb0 + b8cbfe4 commit 56367fe

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

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

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,18 @@ jobs:
77
increment-version:
88
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
99

10-
runs-on: [ubuntu-20.04]
10+
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v2
1515
with:
1616
fetch-depth: 0
1717

18+
# See https://github.com/im-open/git-version-lite for more details around how to increment major/minor/patch through commit messages
1819
- name: Increment the version
19-
uses: actions/github-script@v4
20+
uses: im-open/git-version-lite@v2.0.6
2021
with:
21-
github-token: ${{secrets.GITHUB_TOKEN}}
22-
script: |
23-
const util = require('util');
24-
const exec = util.promisify(require('child_process').exec);
25-
26-
let newTag;
27-
try {
28-
({ stdout: tag } = await exec(`git describe --tags --abbrev=0`));
29-
30-
tag = tag.replace('\n', '').trim();
31-
core.info(`The latest tag is: ${tag}`);
32-
const majorMinorPatch = tag.split('.');
33-
const patch = parseInt(majorMinorPatch[2]) + 1;
34-
newTag = `${majorMinorPatch[0]}.${majorMinorPatch[1]}.${patch}`
35-
core.info(`The new tag is: ${newTag}`);
36-
}
37-
catch (error) {
38-
newTag = 'v1.0.0';
39-
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.');
40-
core.info(error);
41-
}
42-
43-
core.info(`Pushing tag '${newTag}' to the repository...`)
44-
await github.git.createRef({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
ref: `refs/tags/${newTag}`,
48-
sha: context.sha
49-
});
22+
create-ref: true
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
default-release-type: major

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ This action is based on [danielpalme/ReportGenerator-GitHub-Action].
55
[ReportGenerator] converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
66

77
This action does not generate the code coverage reports itself, those must be created by a previous action.
8+
9+
## Index
10+
11+
- [Inputs](#inputs)
12+
- [Usage](#usage)
13+
- [Contributing](#contributing)
14+
- [Recompiling](#recompiling)
15+
- [Incrementing the Version](#incrementing-the-version)
16+
- [Code of Conduct](#code-of-conduct)
17+
- [License](#license)
818

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

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

6373
- name: Create a PR comment from the summary file
64-
uses: im-open/process-code-coverage-summary@v1.0.0
74+
uses: im-open/process-code-coverage-summary@v2.0.2
6575
with:
6676
github-token: ${{ secrets.GITHUB_TOKEN }}
6777
summary-file: '${{ env.CODE_COVERAGE_DIR }}/Summary.md'
6878
create-pr-comment: true
6979
create-status-check: false
7080
```
7181
72-
## Recompiling
82+
## Contributing
83+
84+
When creating new PRs please ensure:
85+
1. The action has been recompiled. See the [Recompiling](#recompiling) section below for more details.
86+
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).
87+
3. The `README.md` example has been updated with the new version. See [Incrementing the Version](#incrementing-the-version).
88+
4. The action code does not contain sensitive information.
89+
90+
### Recompiling
7391

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

@@ -80,6 +98,17 @@ npm run build
8098

8199
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.
82100

101+
### Incrementing the Version
102+
103+
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.
104+
| Increment Type | Commit Message Fragment |
105+
| -------------- | ------------------------------------------- |
106+
| major | +semver:breaking |
107+
| major | +semver:major |
108+
| minor | +semver:feature |
109+
| minor | +semver:minor |
110+
| patch | *default increment type, no comment needed* |
111+
83112
## Code of Conduct
84113

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

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

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

0 commit comments

Comments
 (0)