Add automated release workflow and update configs
Introduced a GitHub Actions workflow to automate release creation upon pushes to the main branch, enhancing CI/CD efficiency. Updated the pull request workflow to support manual triggers. Adjusted Jest's coverage thresholds from 80% to 70% to reflect current testing standards. Added "types" field in package.json for TypeScript declarations. Created an empty README.md.
This commit is contained in:
97
.github/workflows/CreateRelease.yml
vendored
Normal file
97
.github/workflows/CreateRelease.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'package.json'
|
||||
workflow_dispatch: # Allows manual execution of the workflow.
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20.8.0'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run Tests
|
||||
run: npm run test:verbose
|
||||
|
||||
- name: Build the Project
|
||||
run: npm run build:tsc
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: |
|
||||
VERSION=$(npm run version:show | tail -n 1)
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Get previous release tag
|
||||
id: get_previous_release
|
||||
run: |
|
||||
echo "Fetching previous release tag..."
|
||||
previous_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
||||
if [ -z "$previous_tag" ]; then
|
||||
echo "No previous tag found, using initial commit."
|
||||
previous_tag=$(git rev-list --max-parents=0 HEAD)
|
||||
fi
|
||||
echo "Previous tag: $previous_tag"
|
||||
echo "PREVIOUS_TAG=$previous_tag" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Check if version changed
|
||||
id: check_version
|
||||
run: |
|
||||
if [ "${{ env.VERSION }}" == "${{ env.PREVIOUS_TAG }}" ]; then
|
||||
echo "Version has not changed. No release will be created."
|
||||
exit 0
|
||||
fi
|
||||
shell: bash
|
||||
|
||||
- name: Generate release notes
|
||||
id: generate_notes
|
||||
run: |
|
||||
echo "Generating release notes from ${{ env.PREVIOUS_TAG }} to HEAD..."
|
||||
repo_url=$(git config --get remote.origin.url)
|
||||
notes=$(git log ${{ env.PREVIOUS_TAG }}..HEAD --pretty=format:"- [\`%h\`]($repo_url/commit/%H): %s%n")
|
||||
echo "Release notes:"
|
||||
echo "$notes"
|
||||
echo "### Changes in this release" > release_notes.md
|
||||
echo "$notes" >> release_notes.md
|
||||
shell: bash
|
||||
|
||||
- name: Create Tag
|
||||
id: create_tag
|
||||
run: |
|
||||
git tag ${{ env.VERSION }}
|
||||
git push origin ${{ env.VERSION }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: bash
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ env.VERSION }}
|
||||
name: Release ${{ env.VERSION }}
|
||||
body_path: release_notes.md
|
||||
files: |
|
||||
./dist/**
|
||||
./README.md
|
||||
./LICENSE
|
||||
./package.json
|
||||
./tsconfig.json
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
1
.github/workflows/PullRequestTest.yml
vendored
1
.github/workflows/PullRequestTest.yml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch: # Allows manual execution of the workflow.
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
|
@@ -13,10 +13,10 @@ module.exports = {
|
||||
coverageReporters: ['text', 'lcov'],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
branches: 70,
|
||||
functions: 70,
|
||||
lines: 70,
|
||||
statements: 70,
|
||||
},
|
||||
},
|
||||
};
|
@@ -3,6 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build:tsc": "tsc",
|
||||
"lint": "eslint --ext .ts .",
|
||||
|
Reference in New Issue
Block a user