Skip to content

Commit

Permalink
Merge pull request #39 from YOCOING/chore/ci-from-dev-to-main
Browse files Browse the repository at this point in the history
[chore] add CI and release workflow configuration
  • Loading branch information
glassk authored May 11, 2024
2 parents 1517656 + a413bb0 commit 8ac13ab
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Run Tests on PR to Dev
name: Run Tests on PR to Dev and Main

on:
pull_request:
branches:
- dev
- main

jobs:
build-and-test:
Expand All @@ -25,16 +26,16 @@ jobs:
run: npm install -g yarn

- name: Install dependencies
run: yarn install
run: yarn install --frozen-lockfile

- name: Run lint
run: yarn lint

- name: Compile the project
run: yarn compile

- name: Set up Xvfb and Run vscode-test
run: xvfb-run -a yarn test:vscode

- name: Run Mocha tests
run: yarn test:mocha

- name: Compile the project
run: yarn compile
27 changes: 27 additions & 0 deletions .github/workflows/pr-check-version_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Version and Changelog Verification

on:
pull_request:
branches:
- main

jobs:
verify-changes:
runs-on: ubuntu-latest
if: github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'dev'
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for version update in package.json
id: check_version
uses: EndBug/version-check@v2
with:
diff-search: true
assume-same-version: old
static-checking: localIsNew

- name: Enforce CHANGELOG.md update
uses: dangoslen/changelog-enforcer@v3
with:
expectedLatestVersion: ${{ steps.check_version.outputs.version }}
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release Workflow on PR Merge

on:
pull_request:
types: [closed]
branches:
- main

jobs:
create-release:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'dev'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract version from package.json
id: package_version
run: echo "::set-output name=version::$(grep '\"version\"' package.json | cut -d '\"' -f 4)"

- name: Extract Changelog for Current Version
id: changelog
run: |
VERSION=${{ steps.package_version.outputs.version }}
CHANGELOG_CONTENT=$(awk -v ver="$VERSION" 'BEGIN {p=0; first=1} $0 ~ "## \\[" ver "\\]" {p=1; next} /^## \[/ {if(p) exit} p{if (first && /^$/) {first=0; next} print}' CHANGELOG.md)
echo "::set-output name=content::${CHANGELOG_CONTENT}"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package_version.outputs.version }}
release_name: Release v${{ steps.package_version.outputs.version }}
body: ${{ steps.changelog.outputs.content }}

0 comments on commit 8ac13ab

Please sign in to comment.