diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d309a19 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: release + +on: + pull_request: + push: + branches: + - main + - manifest-v3 + +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + pre-commit: + uses: + ./.github/workflows/pre-commit.yml + release: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + - uses: actions/setup-node@v4 + with: + node-version: latest + - name: pushed commits count + id: pushed_commits_count + env: + pushed_commits: ${{ toJson(github.event.commits) }} + run: | + echo "pushed_commits_count=$(echo "$pushed_commits" | jq '. | length')" >> "$GITHUB_OUTPUT" + - run: npm install + - run: npx commitlint --verbose --from HEAD~${{ github.event_name == 'pull_request' && github.event.pull_request.commits || steps.pushed_commits_count.outputs.pushed_commits_count }} --to HEAD + - run: npx semantic-release ${{ github.event_name == 'pull_request' && '--dry-run' || '' }} diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..b4a3bea --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,15 @@ +{ + "branches": [ + "main", + { + "name": "manifest-v3", + "prerelease": true + } + ], + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/npm", + "@semantic-release/release-notes-generator" + ], + "tagFormat": "${ version }" +} diff --git a/package.json b/package.json index c12080e..49473bd 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,10 @@ "@commitlint/cli": "^19.0.3", "@commitlint/config-angular": "^19.0.3", "@eslint/js": "^8.54.0", + "@semantic-release/exec": "github:semantic-release/exec", "@stylistic/eslint-plugin-js": "^1.4.0", "eslint": "^8.54.0", + "semantic-release": "^23.0.2", "web-ext": "^7.8.0" }, "name": "webextension-do-not-close-browser-with-last-tab",