From b8cbfe4c08e1424a133bc2b75cecb6bb258e4ec9 Mon Sep 17 00:00:00 2001 From: Danielle Adams Date: Wed, 24 Nov 2021 15:15:11 -0700 Subject: [PATCH] ARCH-1108 - Standardize the readme and increment version workflow. --- .../workflows/increment-version-on-merge.yml | 37 +++---------------- README.md | 36 ++++++++++++++++-- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/.github/workflows/increment-version-on-merge.yml b/.github/workflows/increment-version-on-merge.yml index 4816a04..3dd1e54 100644 --- a/.github/workflows/increment-version-on-merge.yml +++ b/.github/workflows/increment-version-on-merge.yml @@ -7,7 +7,7 @@ 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 @@ -15,35 +15,10 @@ jobs: 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 diff --git a/README.md b/README.md index 85b6ef0..fc4f58c 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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 }}' @@ -61,7 +71,7 @@ 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' @@ -69,7 +79,15 @@ This action does not generate the code coverage reports itself, those must be cr 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. @@ -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). @@ -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 \ No newline at end of file