Skip to content

Commit

Permalink
ci: Adopt semantic release (#21)
Browse files Browse the repository at this point in the history
* ci: add semantic release bot

* ci: document semantic bot usage

* docs: correct document typo

* ci: remove node v16

* ci: change semantic-release format from YAML to JSON

* chore: convert commitlint config to mjs
  • Loading branch information
haifeng-li-at-salesforce committed Jun 21, 2024
1 parent 9a0bd9f commit 5919aad
Show file tree
Hide file tree
Showing 7 changed files with 11,045 additions and 3,248 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# main is dev integration branch, merge main into release branch to trigger ga release.
name: Release

on:
workflow_dispatch:

jobs:
lint-build-test:
name: Lint, Build, Test - Node ${{ matrix.node-version }} on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version:
- 18.x
- 20.x
os:
- ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm clean-install
- run: npm run lint
- run: npm run build
- run: npm run test

release:
name: Release
needs: lint-build-test # previous job MUST pass to make a release!
runs-on: ubuntu-latest

# Skip running release workflow on forks
if: github.repository_owner == 'salesforce' && github.event_name == 'push'

permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need all git history & tags to determine next release version.
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: 20.x

- name: Install dependencies
run: npm clean-install

- run: npm run build

- name: Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
40 changes: 40 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"branches": ["release-1"],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"type": "docs",
"scope": "README",
"release": "patch"
}
]
}
],
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
}
],
[
"@semantic-release/npm",
{
"npmPublish": true,
"tarballDir": "tarball"
}
],
[
"@semantic-release/github",
{
"assets": "tarball/*.tgz"
}
]
],
"debug": true,
"dryRun": false
}
93 changes: 59 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,87 @@ The intent and goal of open sourcing this project is to increase the contributor
Use GitHub Issues page to submit issues, enhancement requests and discuss ideas.

### Bug Reports and Fixes
- If you find a bug, please search for it in the [Issues](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues), and if it isn't already tracked,
[create a new issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still
be reviewed.
- Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`.
- If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number.
- Include tests that isolate the bug and verifies that it was fixed.

- If you find a bug, please search for it in the [Issues](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues), and if it isn't already tracked,
[create a new issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new). Fill out the "Bug Report" section of the issue template. Even if an Issue is closed, feel free to comment and add details, it will still
be reviewed.
- Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`.
- If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number.
- Include tests that isolate the bug and verifies that it was fixed.

### New Features
- If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new).
- Issues that have been identified as a feature request will be labelled `enhancement`.
- If you'd like to implement the new feature, please wait for feedback from the project
maintainers before spending too much time writing the code. In some cases, `enhancement`s may
not align well with the project objectives at the time.

- If you'd like to add new functionality to this project, describe the problem you want to solve in a [new Issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new).
- Issues that have been identified as a feature request will be labelled `enhancement`.
- If you'd like to implement the new feature, please wait for feedback from the project
maintainers before spending too much time writing the code. In some cases, `enhancement`s may
not align well with the project objectives at the time.

### Tests, Documentation, Miscellaneous
- If you'd like to improve the tests, you want to make the documentation clearer, you have an
alternative implementation of something that may have advantages over the way its currently
done, or you have any other change, we would be happy to hear about it!
- If its a trivial change, go ahead and [send a Pull Request](#creating_a_pull_request) with the changes you have in mind.
- If not, [open an Issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new) to discuss the idea first.

- If you'd like to improve the tests, you want to make the documentation clearer, you have an
alternative implementation of something that may have advantages over the way its currently
done, or you have any other change, we would be happy to hear about it!
- If its a trivial change, go ahead and [send a Pull Request](#creating_a_pull_request) with the changes you have in mind.
- If not, [open an Issue](https://github.com/salesforce/eslint-plugin-lwc-mobile/issues/new) to discuss the idea first.

If you're new to our project and looking for some way to make your first contribution, look for
Issues labelled `good first contribution`.

# Contribution Checklist

- [x] Clean, simple, well styled code
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
- [x] Comments
- Module-level & function-level comments.
- Comments on complex blocks of code or algorithms (include references to sources).
- [x] Tests
- The test suite, if provided, must be complete and pass
- Increase code coverage, not versa.
- Use any of our testkits that contains a bunch of testing facilities you would need. For example: `import com.salesforce.op.test._` and borrow inspiration from existing tests.
- [x] Dependencies
- Minimize number of dependencies.
- Prefer Apache 2.0, BSD3, MIT, ISC and MPL licenses.
- [x] Reviews
- Changes must be approved via peer code review
- [x] Clean, simple, well styled code
- [x] To ensure consistent commit messages, we enforce the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) style. After installing project dependencies with `npm install`, run `npx husky install` to set up automatic commit validation with `commitlint`.
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
- [x] Comments
- Module-level & function-level comments.
- Comments on complex blocks of code or algorithms (include references to sources).
- [x] Tests
- The test suite, if provided, must be complete and pass
- Increase code coverage, not versa.
- Use any of our testkits that contains a bunch of testing facilities you would need. For example: `import com.salesforce.op.test._` and borrow inspiration from existing tests.
- [x] Dependencies
- Minimize number of dependencies.
- Prefer Apache 2.0, BSD3, MIT, ISC and MPL licenses.
- [x] Reviews
- Changes must be approved via peer code review

# Creating a Pull Request

1. **Ensure the bug/feature was not already reported** by searching on GitHub under Issues. If none exists, create a new issue so that other contributors can keep track of what you are trying to add/fix and offer suggestions (or let you know if there is already an effort in progress).
3. **Clone** the forked repo to your machine.
4. **Create** a new branch to contain your work (e.g. `git br fix-issue-11`)
1. **Ensure the bug/feature was not already reported** by searching on GitHub under Issues. If none exists, create a new issue so that other contributors can keep track of what you are trying to add/fix and offer suggestions (or let you know if there is already an effort in progress).
2. **Clone** the forked repo to your machine.
3. **Create** a new branch to contain your work (e.g. `git br fix-issue-11`)
4. **Commit** changes to your own branch.
5. **Push** your work back up to your fork. (e.g. `git push fix-issue-11`)
6. **Submit** a Pull Request against the `main` branch and refer to the issue(s) you are fixing. Try not to pollute your pull request with unintended changes. Keep it simple and small.
7. **Sign** the Salesforce CLA (you will be prompted to do so when submitting the Pull Request)

> **NOTE**: Be sure to [sync your fork](https://help.github.com/articles/syncing-a-fork/) before making a pull request.
# Release Process

### Branching Strategy:

- **Main Branch**: Ongoing development and new features are submitted to the `main` branch.

- **Release Branches**: We'll utilize dedicated branches for managing releases.

- **Major Release:**
- Create a new branch named `release-<major version>` (e.g., `release-2` for a `2.0` release) from `main` to manage the release process.
- Update the `.releaserc.json` file: Locate the `branches` property and specify the newly created release branch name (e.g., `release-2`).
- **Minor/Patch Release:**
- We will use existing major release branches (e.g. `release-2`) for subsequent minor and patch releases (e.g. `2.0.1`, `2.1.2`, etc.).
- Once changes are verified and merged into the release branch, they will be merged back to `main`.

- **Trigger Release Manually:**
- Navigate to the `Actions` tab in GitHub repository.
- Select the `release` workflow from the left sidebar.
- Click the `Run workflow` button to initiate the release process.

# Code of Conduct

Please follow our [Code of Conduct](CODE_OF_CONDUCT.md).

# License
By contributing your code, you agree to license your contribution under the terms of our project [LICENSE](LICENSE.txt) and to sign the [Salesforce CLA](https://cla.salesforce.com/sign-cla)

By contributing your code, you agree to license your contribution under the terms of our project [LICENSE](LICENSE.txt) and to sign the [Salesforce CLA](https://cla.salesforce.com/sign-cla)
15 changes: 15 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

/* This is the pattern from semantic-release */
const automaticCommitPattern = /^chore\(release\):.*\[skip ci\]/;

/** @type {import('@commitlint/types').UserConfig} */
export default {
extends: ['@commitlint/config-conventional'],
ignores: [(commitMsg) => automaticCommitPattern.test(commitMsg)]
};
Loading

0 comments on commit 5919aad

Please sign in to comment.