From 934d447daa7ea5e437696a8bf36d888cbbb930ec Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 2 Jul 2024 13:13:38 +0200 Subject: [PATCH] feat(ci): add package ci --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 37 +++++++++++++++++++++++++ package.json | 51 ++++++++++++++++++++++++++++++++++- 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..50df13e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: blue-reward-programs + +on: + push: + branches: + - main + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint-build-and-test: + name: Lint, Build and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: yarn + + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Lint SDK + run: yarn lint + + - name: Build SDK + run: yarn build + + - name: Test SDK + run: yarn test --coverage + release: + needs: [lint-build-and-test] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: ./.github/workflows/release.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..95f06a4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + workflow_call: + inputs: + node-version: + type: string + default: lts/* + secrets: + NPM_TOKEN: + required: true + +jobs: + semantic-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ inputs.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: yarn + + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Build package + run: yarn build + + - name: Publish package + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/package.json b/package.json index 2ff7d91..692b730 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,54 @@ }, "lint-staged": { "*.ts": "prettier" + }, + "release": { + "branches": [ + "main", + "next" + ], + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "preset": "conventionalcommits", + "releaseRules": [ + { + "type": "build", + "scope": "deps", + "release": "patch" + }, + { + "release": "minor" + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "build", + "section": "Dependencies and Other Build Updates", + "hidden": false + } + ] + } + } + ], + "@semantic-release/npm", + "@semantic-release/github" + ] } -} +} \ No newline at end of file