Skip to content

Commit

Permalink
feat: add Github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jingnanl committed Sep 26, 2023
1 parent db25827 commit 536adf6
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: WeChat SDK Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
code-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run build
run: |
npm i
npm run build
19 changes: 19 additions & 0 deletions .github/workflows/code-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: WeChat SDK Lint

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
code-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run npm install
run: npm i
- name: Run code format
run: npm run format
- name: Run code lint
run: npm run lint
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release next version
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release Tag'
required: true
type: string
env:
NEW_VERSION: ${{ github.event.inputs.release_tag }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
token: ${{ secrets.PROJECT_TOKEN }}
- name: Modify for next release
run: |
chmod +x release.sh
./release.sh ${{ env.NEW_VERSION }}
npm i
git diff
git config user.name '${{ vars.USER_NAME }}'
git config user.email '${{ vars.USER_EMAIL }}'
git add .
git commit -m 'Release: Clickstream WeChat SDK ${{ env.NEW_VERSION }}'
git push
git tag v${{ env.NEW_VERSION }}
git push origin v${{ env.NEW_VERSION }}
- name: Prepare release file
run: |
npm i
npm run release
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: "Clickstream WeChat ${{ env.NEW_VERSION }}"
files: |
dist/clickstream-wechat.min.js
dist/clickstream-webchat.min.js.map
tag_name: "v${{ env.NEW_VERSION }}"
prerelease: true
generate_release_notes: true
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: WeChat SDK Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
code-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run test
run: |
npm i
npm run test
- name: Upload Test Report
uses: codecov/codecov-action@v3
with:
name: report
files: coverage/coverage-final.json
48 changes: 48 additions & 0 deletions .github/workflows/title-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Commit Title Lint

on:
pull_request:
branches: [ "main" ]

jobs:
title-lint:
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed.
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
style
refactor
perf
test
build
ci
chore
revert
release
# Configure that a scope must always be provided.
requireScope: false
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
# For work-in-progress PRs you can typically use draft pull requests
# from Github. However, private repositories on the free plan don't have
# this option and therefore this action allows you to opt-in to using the
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
7 changes: 7 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

version="$1"
echo ${version}
regex="[0-9]\+\.[0-9]\+\.[0-9]\+"

sed -i "s/\"version\": \"${regex}\"/\"version\": \"${version}\"/g" package.json

0 comments on commit 536adf6

Please sign in to comment.