Skip to content

Commit

Permalink
ci!: add automated package release cycle (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
jooyoungseo authored Jan 5, 2024
1 parent 1a2c71d commit 307738a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- To select your options, please put an 'x' in the all boxes that apply. -->

- [ ] I have read the [Contributor Guidelines](../CONTRIBUTING.md).
- [ ] I have updated the [CHANGELOG](../CHANGELOG.md).
- [ ] I have performed a self-review of my own code and ensured it follows the project's coding standards.
- [ ] I have tested the changes locally following `ManualTestingProcess.md`, and all tests related to this pull request pass.
- [ ] I have commented my code, particularly in hard-to-understand areas.
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Daily Release

on:
schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day.
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Check for Meaningful Commits
id: check-commits
run: |
LAST_RELEASE_TAG=$(git describe --tags --abbrev=0)
COMMIT_MESSAGES=$(git log $LAST_RELEASE_TAG..HEAD --pretty=format:%s | tr '[:upper:]' '[:lower:]')
if echo "$COMMIT_MESSAGES" | grep -E '^(feat|fix|perf|docs|refactor)'; then
echo "Meaningful changes detected since the last release."
else
echo "No meaningful changes since the last release. Skipping release process."
echo "::set-output name=skip_release::true"
fi
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'

- name: Install Dependencies
if: steps.check-commits.outputs.skip_release != 'true'
run: yarn install

- name: Generate Documentation
if: steps.check-commits.outputs.skip_release != 'true'
run: yarn docs

- name: Build Project
if: steps.check-commits.outputs.skip_release != 'true'
run: yarn build

- name: Commit Built Files
if: steps.check-commits.outputs.skip_release != 'true'
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add -f dist/
git commit -m "chore: build for release"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run semantic-release
if: steps.check-commits.outputs.skip_release != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn semantic-release
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Please follow these guidelines when contributing to the project:
- Write clear and concise commit messages.
- Follow the code style and formatting guidelines.
- Write tests for new features and bug fixes.
- Update the documentation as needed in `CHANGELOG.md`.

### Code Style and Formatting

Expand Down
22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdoc": "^4.0.2",
"prettier": "^2.8.8"
"prettier": "^2.8.8",
"semantic-release": "^22.0.12"
},
"dependencies": {
"mi": "^1.0.0",
Expand All @@ -52,5 +53,24 @@
},
"jest": {
"testEnvironment": "jsdom"
},
"release": {
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
{
"path": "@semantic-release/git",
"assets": [
"package.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
}
}

0 comments on commit 307738a

Please sign in to comment.