Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: changeset workflows #305

Merged
merged 34 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3bdf6be
feat: add changeset-check workflow
agierlicki Jan 21, 2025
5340598
feat: add changeset release workflow
agierlicki Jan 21, 2025
b5c2a3d
docs: add docs for changeset check workflow
agierlicki Jan 21, 2025
90b2b8c
docs: update readme versions
agierlicki Jan 21, 2025
6e41aff
docs: typo
agierlicki Jan 21, 2025
8f06aa9
fix: add checkout action to changeset check
agierlicki Jan 21, 2025
f27c3e5
fix: fetch and use pr base for diff
agierlicki Jan 21, 2025
87cc068
fix: add origin
agierlicki Jan 21, 2025
915f548
fix: use changed files action to get changesets
agierlicki Jan 21, 2025
1441be8
chore: remove changeset release workflow
agierlicki Jan 22, 2025
f36e2bd
chore: undo version bumps
agierlicki Jan 22, 2025
0e29d34
chore: remove trailing space
agierlicki Jan 22, 2025
83455ca
feat: re-add release workflow
agierlicki Jan 22, 2025
18046aa
feat: re-add release workflow
agierlicki Jan 22, 2025
32b5a5c
docs: improve release docs
agierlicki Jan 22, 2025
6ae02b6
docs: fix job name
agierlicki Jan 22, 2025
5d410f8
docs: add file extensions
agierlicki Jan 22, 2025
922201b
fix: use correct tokens
agierlicki Jan 22, 2025
f26571a
fix: fix typo in filename
agierlicki Jan 22, 2025
136c626
fix: use app token
agierlicki Jan 22, 2025
b759d7d
fix: use app token for checkout
agierlicki Jan 22, 2025
2e201b7
fix: pass npm token correctly
agierlicki Jan 22, 2025
12fff00
fix: don't trigger changeset checks for bot PRs
agierlicki Jan 22, 2025
7493145
ci: debug log npmrc
agierlicki Jan 22, 2025
fc31429
fix: use pnpm for publishing
agierlicki Jan 22, 2025
6c398d8
fix: remove cat
agierlicki Jan 22, 2025
986a857
fix: copy npmrc
agierlicki Jan 22, 2025
b501df5
fix: add debug output
agierlicki Jan 22, 2025
728e201
fix: set home env var
agierlicki Jan 22, 2025
4bad810
fix: add node auth token
agierlicki Jan 22, 2025
e442ee7
chore: review feedback
agierlicki Jan 22, 2025
d8346de
fix: final review feedback
agierlicki Jan 23, 2025
950c92b
docs: add descriptions to readme
agierlicki Jan 23, 2025
b0e4c46
chore: remove input descriptions
agierlicki Jan 23, 2025
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
53 changes: 53 additions & 0 deletions .github/workflows/template_changeset_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Changeset Check

on: workflow_call

jobs:
changeset-check:
name: changeset-check
if: (!contains(github.event.pull_request.user.login , '[bot]'))
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Check for changesets
id: changeset-files
uses: tj-actions/[email protected]
with:
files: .changeset/*.md
base_sha: ${{ github.event.pull_request.base.sha }}

- name: Find existing comment
uses: peter-evans/[email protected]
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: <!-- changeset-check -->

- name: Update comment for found changeset
uses: peter-evans/[email protected]
if: steps.changeset-files.outputs.any_changed == 'true'
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- changeset-check -->
## 🦋 Changeset file found

Good job! A changeset file has been added in this PR. Your changes will be included in the next release.
edit-mode: replace
agierlicki marked this conversation as resolved.
Show resolved Hide resolved

- name: Update comment for missing changeset
uses: peter-evans/[email protected]
if: steps.changeset-files.outputs.any_changed != 'true'
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
<!-- changeset-check -->
## ⚠️ Changeset file missing

No changeset file has been added in this PR. Please consider adding one if this PR contains user-facing changes.
edit-mode: replace
77 changes: 77 additions & 0 deletions .github/workflows/template_changeset_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Changeset Release

on:
workflow_call:
inputs:
node-version-file:
default: '.nvmrc'
required: false
type: string
publish-script:
default: 'pnpm release'
required: false
type: string
version-script:
default: 'pnpm changeset version'
required: false
type: string
node-registry:
required: false
type: string
node-registry-scope:
required: false
type: string
secrets:
app_id:
required: true
private_key:
required: true
npm-token:
required: true

jobs:
release:
name: changeset-release
runs-on: ubuntu-24.04
steps:
- name: Get App Token
uses: actions/[email protected]
id: get_token
with:
app-id: ${{ secrets.app_id }}
private-key: ${{ secrets.private_key }}

- name: Checkout
uses: actions/[email protected]
with:
token: ${{ steps.get_token.outputs.token }}

- name: Setup PNPM
uses: pnpm/[email protected]

- name: Setup Node
uses: actions/[email protected]
with:
node-version-file: ${{ inputs.node-version-file }}
cache: 'pnpm'
registry-url: ${{ inputs.node-registry }}
scope: ${{ inputs.node-registry-scope }}

- name: Install Dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-token }}

- name: Create Release Pull Request
id: changesets
uses: changesets/[email protected]
with:
commit: 'chore(release): Bump package version'
title: '📦 Release New Version'
createGithubReleases: true
version: ${{ inputs.version-script }}
publish: ${{ inputs.publish-script }}
env:
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
HOME: ${{ github.workspace }}
NODE_AUTH_TOKEN: ${{ secrets.npm-token }}
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,64 @@ jobs:

</details>

### Changeset Check
flaxel marked this conversation as resolved.
Show resolved Hide resolved

<details>
<summary>The action can be used to check a PR for the existance of <a href="https://github.com/changesets/changesets">changeset</a> files. It will then add/update a comment on the PR.</summary>

```yml
name: Changeset Check
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
changeset-check:
uses: Staffbase/gha-workflows/.github/workflows/[email protected]
```

</details>

### Changeset Release

<details>
<summary>The action can be used to create release PR and publish releases for repos using PNPM and <a href="https://github.com/changesets/changesets">changesets</a>.</summary>

⚠️ Make sure you have `@changesets/cli` installed as a dev-dependency in your project!

```yml
name: Release Changesets

on:
push:
branches:
- main

jobs:
changeset-release:
uses: Staffbase/gha-workflows/.github/workflows/[email protected]
with:
agierlicki marked this conversation as resolved.
Show resolved Hide resolved
# optional: The file containing the Node.js version to use, defaults to .nvmrc
node-version-file: '.node-version'
# optional: The script to run on publish. Defaults to `pnpm release`
publish-script: 'pnpm publish'
# optional: The script to run for bumping the package versions. Defaults to `pnpm changeset version`
version-script: 'pnpm version'
# optional: The registry to use for Node.js packages.
node-registry: 'https://npm.pkg.github.com/'
# optional: The scope to use for Node.js packages.
node-registry-scope: '@staffbase'
secrets:
# identifier of the GitHub App for authentication
app-id: ${{ <your-app-id> }}
# private key of the GitHub App
private-key: ${{ <your-private-key> }}
# needs write:packages rights
npm-token ${{ <your-npm-token> }}
```

</details>

### GitOps

<details>
Expand Down