-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from YOCOING/chore/ci-from-dev-to-main
[chore] add CI and release workflow configuration
- Loading branch information
Showing
3 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |