From a3ee7d4a72243e79c216a9b0bac35be3794b210a Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Mon, 21 Oct 2024 14:21:30 +0200 Subject: [PATCH] chore: use gh actions (#494) --- .circleci/config.yml | 44 --------------------- .github/workflows/main.yaml | 52 +++++++++++++++++++++++++ .github/workflows/semantic-release.yaml | 22 ----------- .github/workflows/semver-check.yaml | 4 +- .husky/pre-commit | 3 -- package.json | 3 +- 6 files changed, 56 insertions(+), 72 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/main.yaml delete mode 100644 .github/workflows/semantic-release.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a2132d0..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: 2.1 -executors: - node18: - docker: - - image: cimg/node:18.2 - -orbs: - codecov: codecov/codecov@3.3.0 - -commands: - setup: - steps: - - checkout - - run: - name: Installing Dependencies - command: npm ci - - run: - name: prepare test git user - command: git config --global user.email "circleci@example.com" && git config --global user.name "CircleCi Build" - -jobs: - build: - executor: node18 - - steps: - - setup - - run: mkdir junit - - run: - name: Lint - command: npm run lint - - run: - name: Running Tests and Getting Code Coverage - command: npm run test - - codecov/upload - - store_test_results: - path: junit - - store_artifacts: - path: junit - -workflows: - version: 2 - build: - jobs: - - build diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..8e1004c --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,52 @@ +name: Build +on: [push] + +permissions: + contents: write # semantic-release-dry verifies the write permissions + issues: read # needed by semantic-release + pull-requests: write # needed by semantic-release + +env: + CI_BUILD_NUM: ${{ github.run_id }} + CI_BRANCH: ${{ github.ref_name }} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: '18.x' + - run: npm ci + - run: npm run lint + - run: npm test + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + - name: Semantic Release (Dry Run) + run: npm run semantic-release-dry + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} + + release: + name: Release + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + needs: test + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: '18.x' + - run: npm ci + - run: npm run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} diff --git a/.github/workflows/semantic-release.yaml b/.github/workflows/semantic-release.yaml deleted file mode 100644 index 7cfde87..0000000 --- a/.github/workflows/semantic-release.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Semantic Release -on: - push: - branches: - - 'main' - -jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]')" - steps: - - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 - - name: Use Node.js 18.x - uses: actions/setup-node@v4 - with: - node-version: '18.x' - - run: npm install - - run: npm test - - run: npm run semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} diff --git a/.github/workflows/semver-check.yaml b/.github/workflows/semver-check.yaml index e3ae757..a7a4bf6 100644 --- a/.github/workflows/semver-check.yaml +++ b/.github/workflows/semver-check.yaml @@ -10,6 +10,6 @@ jobs: steps: - name: Comment id: comment - uses: adobe-rnd/github-semantic-release-comment-action@master + uses: adobe-rnd/github-semantic-release-comment-action@main with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af219..2312dc5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx lint-staged diff --git a/package.json b/package.json index fa65ff7..2f2b9f2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "test": "c8 mocha", "test-ci": "c8 mocha", "semantic-release": "semantic-release", - "prepare": "husky install" + "semantic-release-dry": "semantic-release --dry-run --branches $CI_BRANCH", + "prepare": "husky" }, "mocha": { "timeout": "5000",