Skip to content

Commit

Permalink
add github action to automate versioning and publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeisonline committed Jan 5, 2025
1 parent e82ce08 commit 61369e9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/scripts/changeset-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// WITH THANKS TO SHADCN, ORIGINALLY FROM CLOUDFLARE WRANGLER:
// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js

import { exec } from "child_process"

// This script is used by the `release.yml` workflow to update the version of the packages being released.
// The standard step is only to run `changeset version` but this does not update the package-lock.json file.
// So we also run `npm install`, which does this update.
// This is a workaround until this is handled automatically by `changeset version`.
// See https://github.com/changesets/changesets/issues/421.
exec("npx changeset version")
exec("npm install")
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Adapted from shadcn/ui

name: Release

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use PNPM
uses: pnpm/action-setup@v4
with:
version: 9.0.6

- name: Use node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Create publish PR or publish directly
id: changesets
uses: changesets/action@v1.4.1
with:
commit: "chore(release): version release"
title: "chore(release): version release"
version: node .github/scripts/changeset-version.js
publish: npx changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_ENV: production

0 comments on commit 61369e9

Please sign in to comment.