Skip to content

Commit e363c45

Browse files
authored
ci: SDKE-548 add CI/CD and semantic release (#50)
1 parent 023a1bb commit e363c45

File tree

8 files changed

+17378
-4571
lines changed

8 files changed

+17378
-4571
lines changed

.github/workflows/deployment.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
node-version: [10.x, 12.x]
16+
node-version: [18.x, 20.x, 22.x, 24.x]
1717

1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v1
21+
uses: actions/setup-node@v3
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
- run: npm ci

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Release Kit
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dryRun:
7+
description: 'Do a dry run to preview instead of a real release [true/false]'
8+
required: true
9+
default: 'true'
10+
11+
jobs:
12+
# Kit release is done from master branch.
13+
confirm-public-repo-master-branch:
14+
name: 'Confirm release is run from public/master branch'
15+
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable
16+
17+
build-and-test:
18+
name: Build and Test
19+
runs-on: ubuntu-latest
20+
needs: confirm-public-repo-master-branch
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: NPM install
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 18.x
29+
30+
- name: Run NPM CI
31+
run: npm ci
32+
33+
- name: Build Files
34+
run: npm run build
35+
36+
- name: Run Core tests
37+
run: npm run test
38+
39+
- name: Archive npm failure logs
40+
uses: actions/upload-artifact@v3
41+
if: failure()
42+
with:
43+
name: npm-logs
44+
path: ~/.npm/_logs
45+
46+
create-release-branch:
47+
name: Create release branch
48+
runs-on: ubuntu-latest
49+
needs:
50+
- build-and-test
51+
- confirm-public-repo-master-branch
52+
steps:
53+
- name: Checkout development branch
54+
uses: actions/checkout@v3
55+
with:
56+
repository: mparticle-integrations/mparticle-javascript-integration-facebook
57+
ref: development
58+
59+
- name: Create and push release branch
60+
run: |
61+
git checkout -b release/${{ github.run_number }}
62+
git push origin release/${{ github.run_number }}
63+
release:
64+
name: Perform Release
65+
runs-on: ubuntu-latest
66+
needs:
67+
- build-and-test
68+
- create-release-branch
69+
- confirm-public-repo-master-branch
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
72+
GIT_AUTHOR_NAME: mparticle-automation
73+
GIT_AUTHOR_EMAIL: developers@mparticle.com
74+
GIT_COMMITTER_NAME: mparticle-automation
75+
GIT_COMMITTER_EMAIL: developers@mparticle.com
76+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
77+
78+
steps:
79+
- name: Checkout public master branch
80+
uses: actions/checkout@v3
81+
with:
82+
fetch-depth: 0
83+
ref: master
84+
85+
- name: Import GPG Key
86+
uses: crazy-max/ghaction-import-gpg@v4
87+
with:
88+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
89+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
90+
git_user_signingkey: true
91+
git_commit_gpgsign: true
92+
93+
- name: Merge release branch into master branch
94+
run: |
95+
git pull origin release/${{ github.run_number }}
96+
- name: Setup Node.js
97+
uses: actions/setup-node@v3
98+
with:
99+
node-version: 18.x
100+
101+
- name: Install dependencies
102+
run: npm ci
103+
104+
- name: Release --dry-run
105+
if: ${{ github.event.inputs.dryRun == 'true'}}
106+
run: |
107+
npx semantic-release --dry-run
108+
- name: Release
109+
if: ${{ github.event.inputs.dryRun == 'false'}}
110+
run: |
111+
npx semantic-release
112+
- name: Archive npm failure logs
113+
uses: actions/upload-artifact@v3
114+
if: failure()
115+
with:
116+
name: npm-logs
117+
path: ~/.npm/_logs
118+
119+
- name: Push automated release commits to release branch
120+
if: ${{ github.event.inputs.dryRun == 'false' }}
121+
run: |
122+
git push origin HEAD:release/${{ github.run_number }}
123+
sync-repository:
124+
name: Sync repositories
125+
needs: release
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Checkout master branch
129+
uses: actions/checkout@v3
130+
with:
131+
fetch-depth: 0
132+
repository: ${{ github.repository }}
133+
token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
134+
ref: master
135+
136+
- name: Merge release branch into master branch
137+
if: ${{ github.event.inputs.dryRun == 'false' }}
138+
run: |
139+
git pull origin release/${{ github.run_number }}
140+
- name: Push release commits to master and development branches
141+
if: ${{ github.event.inputs.dryRun == 'false' }}
142+
run: |
143+
git push origin HEAD:development
144+
git push origin HEAD:master
145+
- name: Delete release branch
146+
if: ${{ github.event.inputs.dryRun == 'false' }}
147+
run: |
148+
git push --delete origin release/${{ github.run_number }}

CONTRIBUTING.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Contributing
2+
3+
Thanks for contributing! Please read this document to follow our conventions for contributing to the mParticle SDK.
4+
5+
## Setting Up
6+
7+
- Fork the repository and then clone down your fork
8+
- Commit your code per the conventions below, and PR into the mParticle Kit `master` branch
9+
- Your PR title will be checked automatically against the below convention (view the commit history to see examples of a proper commit/PR title). If it fails, you must update your title.
10+
- Our engineers will work with you to get your code change implemented once a PR is up
11+
12+
## PR Title and Commit Convention
13+
14+
PR titles should follow [conventional commit standards](https://www.conventionalcommits.org/). This helps automate the release process.
15+
16+
The standard format for commit messages is as follows:
17+
18+
```
19+
<type>[optional scope]: <description>
20+
[optional body]
21+
[optional footer]
22+
```
23+
24+
The following lists the different `types` allowed in the commit message:
25+
26+
- feat: A new feature (automatic minor release)
27+
- fix: A bug fix (automatic patch release)
28+
- docs: Documentation only changes
29+
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
30+
- refactor: A code change that neither fixes a bug nor adds a feature
31+
- perf: A code change that improves performance
32+
- test: Adding missing or correcting existing tests
33+
- chore: Changes that don't modify src or test files, such as automatic documentation generation, or building latest assets
34+
- ci: Changes to CI configuration files/scripts
35+
- revert: Revert commit
36+
- build: Changes that affect the build system or other dependencies
37+
38+
In the footer, if there is a breaking change, start your footer with `BREAKING CHANGE:` followed by a description.
39+
40+
## Running Tests
41+
42+
```bash
43+
$ npm install
44+
$ npm run test // builds mparticle bundles and runs tests
45+
```
46+
47+
There are additional scripts that may improve your development experience:
48+
49+
```bash
50+
$ npm run watch // watches src/ files and continuously rebuilds bundles as changes are made
51+
$ npm run watch:tests // watches test/ files and continuously rebuilds test bundles as changes are made
52+
$ npm run test:debug // opens a browser so you can step through mParticle and test code
53+
```

0 commit comments

Comments
 (0)