Skip to content

Commit

Permalink
build: add automate release
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 13, 2024
1 parent 84a5f49 commit 496ace2
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: main

on:
push:
branches:
- master

jobs:
contributors:
if: "${{ github.event.head_commit.message != 'build: contributors' }}"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Contributors
run: |
git config --global user.email ${{ secrets.GIT_EMAIL }}
git config --global user.name ${{ secrets.GIT_USERNAME }}
npm run contributors
- name: Push changes
run: |
git push origin ${{ github.head_ref }}
release:
if: |
!startsWith(github.event.head_commit.message, 'chore(release):') &&
!startsWith(github.event.head_commit.message, 'docs:') &&
!startsWith(github.event.head_commit.message, 'ci:')
needs: [contributors]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: latest
run_install: true
- name: Test
run: pnpm test
- name: Report
run: npx c8 report --reporter=text-lcov > coverage/lcov.info
- name: Coverage
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
git config --global user.email ${{ secrets.GIT_EMAIL }}
git config --global user.name ${{ secrets.GIT_USERNAME }}
git pull origin master
pnpm run release
36 changes: 36 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: pull_request

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: latest
run_install: true
- name: Test
run: pnpm test
- name: Report
run: npx c8 report --reporter=text-lcov > coverage/lcov.info
- name: Coverage
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@ksmithut/prettier-standard": "latest",
"ava": "latest",
"c8": "latest",
"ci-publish": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"github-generate-release": "latest",
Expand All @@ -60,7 +61,7 @@
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
"coverage": "c8 report --reporter=text-lcov > coverage/lcov.info",
"lint": "standard-markdown README.md && standard",
"postrelease": "npm run release:tags && npm run release:github && npm publish",
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
"prerelease": "npm run update:check",
"pretest": "npm run lint",
"release": "standard-version -a",
Expand Down

0 comments on commit 496ace2

Please sign in to comment.