From 479aab85f0255f60599829fd09a3d29d6567c21d Mon Sep 17 00:00:00 2001 From: Ajesh Sen Thapa Date: Sat, 23 Sep 2023 18:12:43 +0545 Subject: [PATCH] ci: added release-please Added release-please for versioning, changelog generation, github release, and npm publish --- .github/PULL_REQUEST_TEMPLATE.md | 1 - .github/SECURITY.md | 9 +++--- .github/workflows/release-pr.yml | 40 ++++++++++++++++++++++++ .github/workflows/release.yml | 52 ++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 1 - 5 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release-pr.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index efd358b..76f7218 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,7 +22,6 @@ Please mark the appropriate option below to describe the type of change your pul - [ ] I have used [semantic commit messages](https://seesparkbox.com/foundry/semantic_commit_messages). Examples: `"fix: Fixed foobar bug"`, `"feat(accounts): Added foobar feature"`. - [ ] I have added/updated the necessary documentation on `README.md`. -- [ ] I have updated `CHANGELOG.md` for the significant changes. - [ ] I have added appropriate test cases (if applicable) to ensure the changes are functioning correctly. - [ ] My pull request has a clear title and description. diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 5126276..b3a8722 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -6,11 +6,10 @@ The 'node-nepali-datetime' project is committed to maintaining the security and We provide security updates and support for the latest stable release of the 'node-nepali-datetime' package. It is important to keep your software up to date to ensure you have the latest security patches. -| Version | Supported | -| ------- | ------------------ | -| 1.1.x | :white_check_mark: | -| 1.0.x | :white_check_mark: | -| 0.1.0 | :x: | +| Version | Supported | +| --------------- | ------------------ | +| 1.0.0 and above | :white_check_mark: | +| 0.1.0 | :x: | ## Reporting a Vulnerability diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml new file mode 100644 index 0000000..0eacfbf --- /dev/null +++ b/.github/workflows/release-pr.yml @@ -0,0 +1,40 @@ +# This workflow is to create a release PR for a specified version. +# It can be trigger manually with the version as an input. +# Once the PR is merged into main branch the release.yml workflow +# will start the release process. +name: 'Release PR' + +on: + workflow_dispatch: + inputs: + version: + description: 'Enter version (Eg: 1.3.0)' + required: true + +permissions: {} +jobs: + release-please: + permissions: + contents: write # to create release commit (google-github-actions/release-please-action) + pull-requests: write # to create release PR (google-github-actions/release-please-action) + + runs-on: ubuntu-latest + steps: + - name: Display Release version + run: echo "Creating release PR for ${{ github.event.inputs.version }}" + + - name: Create Release PR + uses: google-github-actions/release-please-action@v3 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: node + package-name: nepali-datetime + release-as: '${{ github.event.inputs.version }}' + pull-request-title-pattern: 'chore: release v${version}' + pull-request-header: 'Release PR for v${{ github.event.inputs.version }}' + changelog-types: > + [ + {"type":"fix","section":"Bug Fixes"}, + {"type":"feat","section":"Features"} + ] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab602b1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +# Creates a Github release and NPM publish after the merge of +# release PR created by release-pr.yml +name: 'Release' + +on: + push: + branches: + - main + +permissions: {} +jobs: + release-please: + permissions: + contents: write # to create release commit (google-github-actions/release-please-action) + pull-requests: write # to create release PR (google-github-actions/release-please-action) + + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + command: github-release + release-type: node + package-name: nepali-datetime + + # The logic below handles the npm publication: + - uses: actions/checkout@v2 + # these if statements ensure that a publication only occurs when + # a new release is created: + if: ${{ steps.release.outputs.release_created }} + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} + + - name: Install Dependencies + run: npm ci + if: ${{ steps.release.outputs.release_created }} + + - name: Build + run: npm run build + if: ${{ steps.release.outputs.release_created }} + + - name: Publish to NPM + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 527925e..0fcc9b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,6 @@ Before submitting your Pull Request, please do the following steps: 1. Add any changes you want. 1. Add tests for the new changes. -1. Update the `CHANGELOG.md` file if necessary. 1. Edit documentation (`README.md`) if you have changed something significant. 1. Commit your changes using [semantic commit message](https://seesparkbox.com/foundry/semantic_commit_messages). Examples: `"fix: Fixed foobar bug"`, `"feat(accounts): Added foobar feature on accounts"`.