0
0

More than 1 year has passed since last update.

SemanticRelease整備メモ

Posted at

必要なパッケージを全部インストール

$ npm i -D @semantic-release/changelog @semantic-release/git semantic-release simple-git-hooks @commitlint/config-conventional commitlint
package.json
{
    "scripts": {
        "prepare": "npx simple-git-hooks",
        "commitlint": "commitlint -e $GIT_PARAMS",
    },
      "commitlint": {
    "extends": [
      "@commitlint/config-conventional"
    ]
  },
  "release": {
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      [
        "@semantic-release/npm",
        {
          "npmPublish": false
        }
      ],
      "@semantic-release/github",
      [
        "@semantic-release/git",
        {
          "assets": [
            "package.json",
            "package-lock.json",
            "CHANGELOG.md"
          ],
          "message": "chore(release): v${nextRelease.version}"
        }
      ]
    ],
    "branches": [
      "main"
    ]
  },
  "simple-git-hooks": {
    "commit-msg": "npm run commitlint"
  }
}
workflow.yml
name: Production
on:
  push:
    branches:
      - main
jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
      - name: Cache dependencies
        id: cache
        uses: actions/cache@v2
        with:
          path: ./node_modules
          key: modules-${{ hashFiles('package-lock.json') }}
      - name: Install dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: npm ci
      - run: npx nx build app
      - name: Archive production artifacts
        uses: actions/upload-artifact@v2
        with:
          name: dist
          path: dist
  release:
    name: Release
    runs-on: ubuntu-18.04
    needs: build
    outputs:
      is_released: ${{ steps.result.outputs.is_released }}
      version: ${{ steps.get_version.outputs.version }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
      - name: Cache dependencies
        id: cache
        uses: actions/cache@v2
        with:
          path: ./node_modules
          key: modules-${{ hashFiles('package-lock.json') }}
      - name: Install dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: npm ci
      - name: Download production artifacts
        uses: actions/download-artifact@v2
      - env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: npx semantic-release
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0