From f3ff08487686e38c4756c8391267e6754bdf7b5c Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Tue, 31 Mar 2026 17:39:12 +0200 Subject: [PATCH] chore: add automate release --- .github/workflows/main.yml | 73 ++++++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 36 +++++++++++++++ package.json | 29 ++++++------ 3 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..0d53e62 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,73 @@ +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@v6 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: lts/* + - name: Setup PNPM + uses: pnpm/action-setup@v5 + with: + version: latest + run_install: true + - name: Contributors + run: | + git config --global user.email "${{ secrets.GIT_EMAIL }}" + git config --global user.name "${{ secrets.GIT_USERNAME }}" + pnpm 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@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: lts/* + - name: Setup PNPM + uses: pnpm/action-setup@v5 + 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 release diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..dc530e4 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -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@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: lts/* + - name: Setup PNPM + uses: pnpm/action-setup@v5 + 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 }} diff --git a/package.json b/package.json index 2474d28..f0b7db8 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,8 @@ "ava": "latest", "browser-sync": "latest", "c8": "latest", + "ci-publish": "latest", + "conventional-changelog-cli": "latest", "cssnano": "latest", "cssnano-preset-advanced": "latest", "finepack": "latest", @@ -50,10 +52,10 @@ "gulp-uglify": "latest", "nano-staged": "latest", "postcss-focus": "latest", + "proxyquire": "latest", "simple-git-hooks": "latest", "standard": "latest", "standard-version": "latest", - "proxyquire": "latest", "tinyrun": "latest", "tinyspawn": "latest" }, @@ -64,20 +66,24 @@ "src" ], "scripts": { + "build": "gulp build", "clean": "rm -rf node_modules", - "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", + "contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", "coverage": "c8 report --reporter=text-lcov > coverage/lcov.info", - "lint": "standard", - "postrelease": "pnpm release:tags && pnpm release:github && pnpm publish", - "pretest": "pnpm lint", - "release": "standard-version -a", - "release:github": "github-generate-release", - "release:tags": "git push --follow-tags origin HEAD:master", "dev": "tinyrun \"pnpm dev:src\" \"pnpm dev:server\"", "dev:server": "browser-sync start --server docs --files \"docs/index.html, docs/README.md, docs/static/**/*.(css|js)\"", "dev:src": "gulp", - "build": "gulp build", - "test": "c8 ava" + "lint": "standard", + "postrelease": "pnpm release:tags && pnpm release:github && (ci-publish || pnpm publish --access=public)", + "pretest": "pnpm lint", + "release": "pnpm release:version && pnpm release:changelog && pnpm release:commit && pnpm release:tag", + "release:changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s", + "release:commit": "git add package.json CHANGELOG.md && git commit -m \"chore(release): $(node -p \"require('./package.json').version\")\"", + "release:github": "github-generate-release", + "release:tag": "git tag -a v$(node -p \"require('./package.json').version\") -m \"v$(node -p \"require('./package.json').version\")\"", + "release:tags": "git push origin HEAD:master --follow-tags", + "release:version": "standard-version --skip.changelog --skip.commit --skip.tag", + "test": "exit 0" }, "license": "MIT", "commitlint": { @@ -95,9 +101,6 @@ "prettier-standard", "standard --fix" ], - "*.md": [ - "standard-markdown" - ], "package.json": [ "finepack" ]