From 34a8ffc0490b1f4d2bf7ee201e49e586f8f6e492 Mon Sep 17 00:00:00 2001 From: Okiki Date: Sun, 1 Jan 2023 04:25:55 +0000 Subject: [PATCH] ci: add release workflow --- .github/workflows/release.yml | 52 ++++++++++++++++++++++++++++++ package.json | 59 +++++++++++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1760b3a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: Release +on: workflow_dispatch + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + # File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .tool-versions. + node-version: 18 + + - name: Install + run: | + npm install + + - name: Pre-release + run: npm run build + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm run semantic-release + + - name: Add lib, types and docs to Git + if: ${{ github.ref == 'refs/heads/master' }} + run: | + git add --force dist + + - name: Commit files + if: ${{ github.ref == 'refs/heads/master' }} + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "chore(gh-bot): :rocket: release" -a + + - name: Push changes + if: ${{ github.ref == 'refs/heads/master' }} + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} \ No newline at end of file diff --git a/package.json b/package.json index da32c12..a8e6e19 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,11 @@ { "version": "0.0.0", "name": "resolve.imports", - "repository": "okikio/resolve.imports", + "type": "module", + "repository": { + "type": "git", + "url": "https://github.com/okikio/resolve.imports.git" + }, "description": "A tiny (613b), correct, general-purpose, and configurable subpath \"imports\" resolver without file-system reliance (forked from @lukeed's `resolve.exports`)", "module": "dist/index.mjs", "main": "dist/index.js", @@ -12,12 +16,16 @@ "email": "hey@okikio.dev", "url": "https://okikio.dev" }, + "bugs": { + "url": "https://github.com/okikio/resolve.imports/issues" + }, "engines": { "node": ">=10" }, "scripts": { "build": "bundt", - "test": "uvu -r esm test" + "test": "uvu -r esm test", + "semantic-release": "semantic-release" }, "files": [ "*.d.ts", @@ -43,6 +51,51 @@ "devDependencies": { "bundt": "1.1.2", "esm": "3.2.25", - "uvu": "0.5.1" + "uvu": "0.5.1", + "@commitlint/cli": "^17.1.2", + "@commitlint/config-conventional": "^17.1.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/git": "^10.0.1", + "husky": "^8.0.1", + "semantic-release": "^19.0.5" + }, + "release": { + "branches": [ + "main", + "master" + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + "@semantic-release/git", + "@semantic-release/npm", + [ + "@semantic-release/github", + { + "assets": [ + "*.d.ts", + "dist" + ] + } + ] + ] + }, + "changelog": { + "repo": "resolve.imports", + "labels": { + "breaking": ":boom: Breaking Change", + "enhancement": ":rocket: Enhancement", + "bug": ":bug: Bug Fix", + "documentation": ":memo: Documentation", + "internal": ":house: Internal", + "revert": ":rewind: Revert" + }, + "cacheDir": ".changelog" + }, + "husky": { + "hooks": { + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --verbose" + } } }