Skip to content

Commit

Permalink
ci(release): replace semantic-release with changesets release
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Aug 21, 2023
1 parent b2dbb71 commit 9d0e890
Show file tree
Hide file tree
Showing 9 changed files with 2,107 additions and 291 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
8 changes: 8 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "okonet/lint-staged" }],
"commit": true,
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch"
}
2 changes: 2 additions & 0 deletions .changeset/rich-gifts-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
54 changes: 42 additions & 12 deletions .github/workflows/main.yml → .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ name: Test & Release

on:
push:
# Run on pushes to specific branches
branches:
- master
- beta
- alpha
# Do not run on tags
tags-ignore:
- '*'
Expand All @@ -19,13 +16,15 @@ jobs:
install:
uses: ./.github/workflows/install.yml

lint:
name: ESLint
changesets:
if: github.event_name == 'pull_request'
needs:
- install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
Expand All @@ -37,7 +36,7 @@ jobs:
key: ubuntu-latest-20-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
ubuntu-latest-20-${{ hashFiles('**/package-lock.json') }}
- run: npm run lint
- run: npx changeset status --since=${{ github.event.pull_request.base.sha }}

commitlint:
if: github.event_name == 'pull_request'
Expand All @@ -61,6 +60,26 @@ jobs:
ubuntu-latest-20-${{ hashFiles('**/package-lock.json') }}
- run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

lint:
name: ESLint
needs:
- install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
# Install node_modules
- uses: actions/cache@v3
id: cache-node_modules
with:
path: node_modules
key: ubuntu-latest-20-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
ubuntu-latest-20-${{ hashFiles('**/package-lock.json') }}
- run: npm run lint

test:
needs:
- install
Expand Down Expand Up @@ -119,7 +138,6 @@ jobs:
name: Codecov
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v3
Expand All @@ -138,16 +156,28 @@ jobs:
needs:
- lint
- test
- codecov
# Trigger release for only pushes to branches defined above
if: github.event_name == 'push'
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
# Release using semantic-release.
# While this runs on all branches, it will only release latest from master
- uses: codfish/semantic-release-action@v2
- uses: actions/cache@v3
id: cache-node_modules
with:
path: node_modules
key: ${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node_modules.outputs.cache-hit != 'true'
run: npm ci
- name: Create Release Pull Request
uses: changesets/action@v1
with:
commit: 'chore(release): bump version'
title: 'chore(release): bump version'
publish: npx changeset tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish

on:
push:
tags:
# Semver-like tags "v1.0.0", or "v.0.0.1-beta.1"
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no changeset status
18 changes: 0 additions & 18 deletions .releaserc.json

This file was deleted.

Loading

0 comments on commit 9d0e890

Please sign in to comment.