Daily Release #1
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
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 |