Skip to content

Commit 5919aad

Browse files
ci: Adopt semantic release (#21)
* 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
1 parent 9a0bd9f commit 5919aad

File tree

7 files changed

+11045
-3248
lines changed

7 files changed

+11045
-3248
lines changed

.github/workflows/release.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# main is dev integration branch, merge main into release branch to trigger ga release.
2+
name: Release
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
lint-build-test:
9+
name: Lint, Build, Test - Node ${{ matrix.node-version }} on ${{ matrix.os }}
10+
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
node-version:
15+
- 18.x
16+
- 20.x
17+
os:
18+
- ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Install dependencies
29+
run: npm clean-install
30+
- run: npm run lint
31+
- run: npm run build
32+
- run: npm run test
33+
34+
release:
35+
name: Release
36+
needs: lint-build-test # previous job MUST pass to make a release!
37+
runs-on: ubuntu-latest
38+
39+
# Skip running release workflow on forks
40+
if: github.repository_owner == 'salesforce' && github.event_name == 'push'
41+
42+
permissions:
43+
contents: write # to be able to publish a GitHub release
44+
issues: write # to be able to comment on released issues
45+
pull-requests: write # to be able to comment on released pull requests
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0 # Need all git history & tags to determine next release version.
52+
persist-credentials: false
53+
54+
- name: Use Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
cache: npm
58+
node-version: 20.x
59+
60+
- name: Install dependencies
61+
run: npm clean-install
62+
63+
- run: npm run build
64+
65+
- name: Release
66+
run: npx semantic-release
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.husky/commit-msg

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

.releaserc.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"branches": ["release-1"],
3+
"plugins": [
4+
[
5+
"@semantic-release/commit-analyzer",
6+
{
7+
"preset": "conventionalcommits",
8+
"releaseRules": [
9+
{
10+
"type": "docs",
11+
"scope": "README",
12+
"release": "patch"
13+
}
14+
]
15+
}
16+
],
17+
"@semantic-release/release-notes-generator",
18+
[
19+
"@semantic-release/changelog",
20+
{
21+
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
22+
}
23+
],
24+
[
25+
"@semantic-release/npm",
26+
{
27+
"npmPublish": true,
28+
"tarballDir": "tarball"
29+
}
30+
],
31+
[
32+
"@semantic-release/github",
33+
{
34+
"assets": "tarball/*.tgz"
35+
}
36+
]
37+
],
38+
"debug": true,
39+
"dryRun": false
40+
}

CONTRIBUTING.md

+59-34
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,87 @@ The intent and goal of open sourcing this project is to increase the contributor
1313
Use GitHub Issues page to submit issues, enhancement requests and discuss ideas.
1414

1515
### Bug Reports and Fixes
16-
- 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,
17-
[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
18-
be reviewed.
19-
- Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`.
20-
- If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number.
21-
- Include tests that isolate the bug and verifies that it was fixed.
16+
17+
- 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,
18+
[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
19+
be reviewed.
20+
- Issues that have already been identified as a bug (note: able to reproduce) will be labelled `bug`.
21+
- If you'd like to submit a fix for a bug, [send a Pull Request](#creating_a_pull_request) and mention the Issue number.
22+
- Include tests that isolate the bug and verifies that it was fixed.
2223

2324
### New Features
24-
- 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).
25-
- Issues that have been identified as a feature request will be labelled `enhancement`.
26-
- If you'd like to implement the new feature, please wait for feedback from the project
27-
maintainers before spending too much time writing the code. In some cases, `enhancement`s may
28-
not align well with the project objectives at the time.
25+
26+
- 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).
27+
- Issues that have been identified as a feature request will be labelled `enhancement`.
28+
- If you'd like to implement the new feature, please wait for feedback from the project
29+
maintainers before spending too much time writing the code. In some cases, `enhancement`s may
30+
not align well with the project objectives at the time.
2931

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

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

4043
# Contribution Checklist
4144

42-
- [x] Clean, simple, well styled code
43-
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
44-
- [x] Comments
45-
- Module-level & function-level comments.
46-
- Comments on complex blocks of code or algorithms (include references to sources).
47-
- [x] Tests
48-
- The test suite, if provided, must be complete and pass
49-
- Increase code coverage, not versa.
50-
- 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.
51-
- [x] Dependencies
52-
- Minimize number of dependencies.
53-
- Prefer Apache 2.0, BSD3, MIT, ISC and MPL licenses.
54-
- [x] Reviews
55-
- Changes must be approved via peer code review
45+
- [x] Clean, simple, well styled code
46+
- [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`.
47+
- [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number.
48+
- [x] Comments
49+
- Module-level & function-level comments.
50+
- Comments on complex blocks of code or algorithms (include references to sources).
51+
- [x] Tests
52+
- The test suite, if provided, must be complete and pass
53+
- Increase code coverage, not versa.
54+
- 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.
55+
- [x] Dependencies
56+
- Minimize number of dependencies.
57+
- Prefer Apache 2.0, BSD3, MIT, ISC and MPL licenses.
58+
- [x] Reviews
59+
- Changes must be approved via peer code review
5660

5761
# Creating a Pull Request
5862

59-
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).
60-
3. **Clone** the forked repo to your machine.
61-
4. **Create** a new branch to contain your work (e.g. `git br fix-issue-11`)
63+
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).
64+
2. **Clone** the forked repo to your machine.
65+
3. **Create** a new branch to contain your work (e.g. `git br fix-issue-11`)
6266
4. **Commit** changes to your own branch.
6367
5. **Push** your work back up to your fork. (e.g. `git push fix-issue-11`)
6468
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.
6569
7. **Sign** the Salesforce CLA (you will be prompted to do so when submitting the Pull Request)
6670

6771
> **NOTE**: Be sure to [sync your fork](https://help.github.com/articles/syncing-a-fork/) before making a pull request.
6872
73+
# Release Process
74+
75+
### Branching Strategy:
76+
77+
- **Main Branch**: Ongoing development and new features are submitted to the `main` branch.
78+
79+
- **Release Branches**: We'll utilize dedicated branches for managing releases.
80+
81+
- **Major Release:**
82+
- Create a new branch named `release-<major version>` (e.g., `release-2` for a `2.0` release) from `main` to manage the release process.
83+
- Update the `.releaserc.json` file: Locate the `branches` property and specify the newly created release branch name (e.g., `release-2`).
84+
- **Minor/Patch Release:**
85+
- 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.).
86+
- Once changes are verified and merged into the release branch, they will be merged back to `main`.
87+
88+
- **Trigger Release Manually:**
89+
- Navigate to the `Actions` tab in GitHub repository.
90+
- Select the `release` workflow from the left sidebar.
91+
- Click the `Run workflow` button to initiate the release process.
6992

7093
# Code of Conduct
94+
7195
Please follow our [Code of Conduct](CODE_OF_CONDUCT.md).
7296

7397
# License
74-
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)
98+
99+
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)

commitlint.config.mjs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2024, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
/* This is the pattern from semantic-release */
9+
const automaticCommitPattern = /^chore\(release\):.*\[skip ci\]/;
10+
11+
/** @type {import('@commitlint/types').UserConfig} */
12+
export default {
13+
extends: ['@commitlint/config-conventional'],
14+
ignores: [(commitMsg) => automaticCommitPattern.test(commitMsg)]
15+
};

0 commit comments

Comments
 (0)