From 7115aade10042e4b93135189ab9620e3663b30a0 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Wed, 2 Jul 2025 10:16:55 +0200 Subject: [PATCH] ci: add automate releases --- .github/dependabot.yml | 8 +++--- .github/workflows/main.yml | 40 ++++++++++++++++++++++++------ .github/workflows/pull_request.yml | 38 ++++++++++++++++++++++++++++ package.json | 1 - 4 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2578409..b479c92 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,11 @@ version: 2 updates: - package-ecosystem: npm - directory: "/" + directory: '/' schedule: interval: daily - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: # Check for updates to GitHub Actions every weekday - interval: "daily" + interval: 'daily' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d9eb111..328d07c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,20 +1,19 @@ -name: test +name: main on: push: branches: - master - pull_request: - branches: - - master jobs: - test: + 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: Start Redis uses: supercharge/redis-github-action@1.8.0 @@ -22,13 +21,38 @@ jobs: 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: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* - name: Setup PNPM uses: pnpm/action-setup@v4 with: version: latest run_install: true - name: Test - run: npm test + run: pnpm test - name: Report run: npx c8 report --reporter=text-lcov > coverage/lcov.info - name: Coverage @@ -36,11 +60,11 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Release - if: ${{ github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'chore(release):') && !startsWith(github.event.head_commit.message, 'docs:') }} 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 }} - npm run release + git pull origin master + pnpm run release diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..014ccc5 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,38 @@ +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: Start Redis + uses: supercharge/redis-github-action@1.8.0 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Setup PNPM + uses: pnpm/action-setup@v4 + 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 84a17f6..3091b59 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", "lint": "standard-markdown README.md && standard", "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)", - "prerelease": "npm run contributors", "pretest": "npm run lint", "release": "standard-version -a", "release:github": "github-generate-release",