From 95d195c962eddac48db1024c0c4da0c321401176 Mon Sep 17 00:00:00 2001 From: Rafe Goldberg Date: Mon, 25 Oct 2021 07:12:52 -0700 Subject: [PATCH] feat: set up release workflow --- .github/workflows/release.yml | 60 ++++++++++++++++++++++++++++ .releaserc.js | 74 +++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .releaserc.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b3fce8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + semantic-release: + name: Release + if: "!contains(github.event.head_commit.message, 'SKIP CI')" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [14.x] + steps: + - name: Checkout branch (${{ github.ref }}) + uses: actions/checkout@master + - name: Configure git + run: | + git config user.name "Action" + git config user.email "rafegoldberg@gmail.com" + - name: Setup node (v${{ matrix.node-version }}) + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install packages + run: | + npm ci + npm run build --if-present + env: + CI: true + - name: Install release dependencies + # see: https://github.com/semantic-release/changelog/issues/168 + run: npm i --no-save @semantic-release/changelog@5 @semantic-release/exec@5 @semantic-release/git@9 + - name: Build release + run: npm run release + env: + GH_TOKEN: ${{ secrets.GITHUB_ADMIN || secrets.GITHUB_TOKEN }} # push release to remote repo + NPM_TOKEN: ${{ secrets.NPM_TOKEN || secrets.GITHUB_TOKEN }} # publish package to registry + - name: Sync to remote + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + continue-on-error: true + - name: Sync to next + if: "github.ref == 'refs/heads/master'" + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: next + continue-on-error: true + - name: Save bundle + uses: actions/upload-artifact@v1 + with: + name: Bundle + path: dist + continue-on-error: true \ No newline at end of file diff --git a/.releaserc.js b/.releaserc.js new file mode 100644 index 0000000..a656585 --- /dev/null +++ b/.releaserc.js @@ -0,0 +1,74 @@ +module.exports = { + ci: false, + branches: ["master", { name: "next", prerelease: true }], + plugins: [ + [ + "@semantic-release/commit-analyzer", + { + preset: "angular", + releaseRules: [ + { type: "feat", release: "minor" }, + { type: "style", release: "patch" }, + { type: "refactor", release: "patch" }, + { scope: "skip", release: false }, + ], + parserOpts: { + noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"], + }, + }, + ], + [ + "@semantic-release/release-notes-generator", + { + preset: "conventionalcommits", + presetConfig: { + types: [ + { type: "feat", section: "✨ New & Improved", hidden: false }, + { type: "refactor", section: "✨ New & Improved", hidden: true }, + + { type: "style", section: "💄 Style Refinements", hidden: false }, + + { type: "fix", section: "🛠 Fixes & Updates", hidden: false }, + { type: "perf", section: "🛠 Fixes & Updates", hidden: false }, + { type: "chore", section: "🛠 Fixes & Updates", hidden: true }, + { type: "test", section: "🛠 Fixes & Updates", hidden: true }, + + { type: "docs", section: "📘 Docs", hidden: false }, + + { type: "build", hidden: true }, + { type: "ci", hidden: true }, + ], + }, + parserOpts: { + noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"], + }, + writerOpts: { + commitsSort: ["subject", "scope"], + headerPartial: `## Version {{version}}`, + }, + }, + ], + [ + "@semantic-release/changelog", + { + changelogTitle: "Changelog\n===", + }, + ], + [ + "@semantic-release/npm", + { + npmPublish: false, + tarballDir: "dist", + }, + ], + ["@semantic-release/github"], + [ + "@semantic-release/git", + { + assets: ["CHANGELOG.md", "package.json", "package-lock.json"], + message: + "Release v${nextRelease.version}\n\n${nextRelease.notes}\n", + }, + ], + ], +}; \ No newline at end of file