Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Setup CI
description: Sets up pnpm, Node.js, and installs dependencies

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
- name: Set up pnpm
uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: ".node-version"
cache: yarn
cache: pnpm

- name: Install dependencies
shell: bash
run: yarn install --frozen-lockfile
run: pnpm install --frozen-lockfile
33 changes: 23 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,50 @@ name: CI
on:
pull_request:
push:
branches: [main]
branches:
- main
merge_group:
branches: [main]
branches:
- main

permissions:
contents: read
permissions: {}

jobs:
test:
name: Test
timeout-minutes: 20
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/ci-setup
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup dependencies
uses: ./.github/actions/ci-setup

- name: Test
run: yarn test
run: pnpm test

typecheck:
name: Typecheck
timeout-minutes: 20
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/ci-setup
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup dependencies
uses: ./.github/actions/ci-setup

- name: Typecheck
run: yarn typecheck
run: pnpm typecheck

ci-ok:
name: CI OK
Expand Down
59 changes: 45 additions & 14 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,30 @@ name: Release PR

on:
issue_comment:
types: [created]
types:
- created

permissions: {}

jobs:
release_check:
if: github.repository == 'changesets/action' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/release-pr')
timeout-minutes: 5
runs-on: ubuntu-latest

permissions:
issues: write

steps:
- id: report_in_progress
- name: Report in progress
id: report_in_progress
run: |
echo "in_progress_reaction_id=$(gh api /repos/${{github.repository}}/issues/comments/${{github.event.comment.id}}/reactions -f content='eyes' --jq '.id')" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- id: check_authorization
- name: Check authorization
id: check_authorization
run: |
if [[ $AUTHOR_ASSOCIATION == 'MEMBER' || $AUTHOR_ASSOCIATION == 'OWNER' || $AUTHOR_ASSOCIATION == 'COLLABORATOR' ]]
then
Expand All @@ -35,9 +45,18 @@ jobs:
timeout-minutes: 20
runs-on: ubuntu-latest
needs: release_check

permissions:
contents: read
issues: write
pull-requests: write

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/ci-setup
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup dependencies
uses: ./.github/actions/ci-setup

- name: Checkout pull request
run: gh pr checkout ${{ github.event.issue.number }}
Expand All @@ -55,30 +74,34 @@ jobs:
if: steps.check_version_packages.outputs.version_packages == 'true'
run: git reset --hard HEAD~1

- run: yarn changeset version --snapshot pr${{ github.event.issue.number }}
- name: Create snapshot version
run: pnpm changeset version --snapshot pr${{ github.event.issue.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: yarn build
run: pnpm build

- name: Setup Git user
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Release snapshot version
run: yarn run release:pr
run: pnpm release:pr

- run: gh api /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content='rocket'
- name: Add success reaction
run: gh api /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content='rocket'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: gh api -X DELETE /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions/${{ needs.release_check.outputs.in_progress_reaction_id }}
- name: Remove in-progress reaction
run: gh api -X DELETE /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions/${{ needs.release_check.outputs.in_progress_reaction_id }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: gh pr comment ${{ github.event.issue.number }} --body "The [${{ github.repository }}@$(git rev-parse HEAD)](https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)) release triggered by [this comment](${{ github.event.comment.url }}) has [succeeded](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
- name: Comment success
run: gh pr comment ${{ github.event.issue.number }} --body "The [${{ github.repository }}@$(git rev-parse HEAD)](https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)) release triggered by [this comment](${{ github.event.comment.url }}) has [succeeded](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -87,16 +110,24 @@ jobs:
timeout-minutes: 2
runs-on: ubuntu-latest
if: failure() && github.repository == 'changesets/action' && (needs.release_check.result == 'failure' || needs.release.result == 'failure')

permissions:
issues: write
pull-requests: write

steps:
- run: gh api /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content='-1'
- name: Add failure reaction
run: gh api /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions -f content='-1'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: gh api -X DELETE /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions/${{ needs.release_check.outputs.in_progress_reaction_id }}
- name: Remove in-progress reaction
run: gh api -X DELETE /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions/${{ needs.release_check.outputs.in_progress_reaction_id }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: gh pr comment ${{ github.event.issue.number }} --body "The release triggered by [this comment](${{ github.event.comment.url }}) has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
- name: Comment failure
run: gh pr comment ${{ github.event.issue.number }} --body "The release triggered by [this comment](${{ github.event.comment.url }}) has [failed](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
21 changes: 16 additions & 5 deletions .github/workflows/version-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ on:

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions: {}

jobs:
changesets:
timeout-minutes: 20
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/ci-setup
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup dependencies
uses: ./.github/actions/ci-setup

- name: Build
run: yarn build
run: pnpm build

- name: Create Release Pull Request or Publish
id: changesets
uses: ./
with:
version: yarn bump
publish: yarn release
version: pnpm bump
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 37 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This action for [Changesets](https://github.com/changesets/changesets) creates a
- published - A boolean value to indicate whether a publishing has happened or not
- publishedPackages - A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`

### Example workflow:
### Example workflow

#### Without Publishing

Expand All @@ -42,15 +42,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Setup Node.js 20
uses: actions/setup-node@v3
- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 22

- name: Install Dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request
uses: changesets/action@v1
Expand All @@ -76,22 +79,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js 20.x
uses: actions/setup-node@v3
- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: 20.x
node-version: 22

- name: Install Dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
publish: pnpm release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand All @@ -103,7 +109,7 @@ jobs:

By default the GitHub Action creates a `.npmrc` file with the following content:

```
```txt
//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}
```

Expand Down Expand Up @@ -140,15 +146,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Setup Node.js 20.x
uses: actions/setup-node@v3
- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: 20.x
node-version: 22

- name: Install Dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand All @@ -157,7 +166,7 @@ jobs:
- name: Publish
if: steps.changesets.outputs.hasChangesets == 'false'
# You can do something when a publish should happen.
run: yarn publish
run: pnpm publish
```

#### With version script
Expand All @@ -182,21 +191,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js 20.x
uses: actions/setup-node@v3
- name: Setup Node.js 22
uses: actions/setup-node@v6
with:
node-version: 20.x
node-version: 22

- name: Install Dependencies
run: yarn
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request
uses: changesets/action@v1
with:
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
version: yarn version
version: pnpm version
```

#### With Yarn 2 / Plug'n'Play
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/simple-project/packages/pkg-a/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-project-pkg-a",
"name": "@simple-project/pkg-a",
"version": "1.0.0",
"dependencies": {
"simple-project-pkg-b": "1.0.0"
"@simple-project/pkg-b": "1.0.0"
}
}
2 changes: 1 addition & 1 deletion __fixtures__/simple-project/packages/pkg-b/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "simple-project-pkg-b",
"name": "@simple-project/pkg-b",
"version": "1.0.0"
}
Loading