diff --git a/.github/workflows/publish-source-code.yml b/.github/workflows/publish-source-code.yml deleted file mode 100644 index 33ebfab..0000000 --- a/.github/workflows/publish-source-code.yml +++ /dev/null @@ -1,56 +0,0 @@ -on: - push: - tags: - - 'v*' - workflow_dispatch: {} - -name: Publish -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: https://registry.npmjs.org/ - - - name: Restore project deps - run: npm ci - - - name: Build the package next-youtube-livechat - run: cd packages/next-youtube-livechat && npm run build - - - name: Lint check - run: npm run lint - - - name: Code format check - run: npm run format - - - name: Typescript check - run: npm run typecheck - - - run: cd packages/next-youtube-livechat && npm publish - env: - NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - NODE_ENV: 'production' - - github-release: - needs: publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: https://registry.npmjs.org/ - - run: npm i -g github-release-from-changelog - - run: github-release-from-changelog - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_ENV: 'production' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8f1382d..3c58b80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,12 @@ -name: Release +# trigger only when packages code modified are merged on main branch +name: Bump version & publish to NPM on: push: - branches: [master] - # paths: - # - 'packages/next-youtube-livechat/**' + branches: + - main + paths: + - 'packages/next-youtube-livechat/**' workflow_dispatch: {} jobs: @@ -12,16 +14,13 @@ jobs: name: Release if: ${{ github.repository_owner == 'sawaYch' }} runs-on: ubuntu-latest - # permissions: - # contents: write - # deployments: write - # packages: write - # pull-requests: write + permissions: + contents: write # to create release (changesets/action) + issues: write # to post issue comments (changesets/action) + pull-requests: write # to create pull request (changesets/action) steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 2 - name: Setup Node.js 20 uses: actions/setup-node@v4 @@ -31,26 +30,29 @@ jobs: - name: Restore dependencies run: npx ci - - name: Install semantic-release extra plugins - run: npm install --save-dev @semantic-release/changelog @semantic-release/git - - - name: Restore project deps - run: npm ci - - name: Build the package next-youtube-livechat - run: cd packages/next-youtube-livechat && npm run build + run: npm run build + working-directory: packages/next-youtube-livechat - name: Lint check run: npm run lint + working-directory: packages/next-youtube-livechat - name: Code format check run: npm run format + working-directory: packages/next-youtube-livechat - name: Typescript check run: npm run typecheck + working-directory: packages/next-youtube-livechat - - name: Release + - name: Create Release Pull Request or Publish to npm + uses: changesets/action@v1 + with: + publish: npm run release + version: npm run version + commit: 'chore: new release' + title: 'chore: new release candidate' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} - run: npx semantic-release + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 2cb5bb7..787b61a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "lint": "turbo run lint", "format": "turbo run format", "format:fix": "turbo run format:fix", - "typecheck": "turbo run typecheck" + "typecheck": "turbo run typecheck", + "version": "turbo run version", + "release": "turbo run release" }, "devDependencies": { "@changesets/changelog-github": "^0.5.0", diff --git a/packages/next-youtube-livechat/package.json b/packages/next-youtube-livechat/package.json index f07494b..77bcdcd 100644 --- a/packages/next-youtube-livechat/package.json +++ b/packages/next-youtube-livechat/package.json @@ -29,7 +29,9 @@ "lint": "eslint --ext .ts,.tsx", "format": "npx prettier -c \"**/*.{ts,tsx,css}\"", "format:fix": "npx prettier -w \"**/*.{ts,tsx,css}\"", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "version": "npx changeset version", + "release": "npx changeset publish" }, "dependencies": { "next": "^14.1.1", diff --git a/turbo.json b/turbo.json index 54c5b0e..c6ea844 100644 --- a/turbo.json +++ b/turbo.json @@ -23,6 +23,12 @@ }, "dev": { "cache": false + }, + "release": { + "cache": false + }, + "version": { + "cache": false } } }