Skip to content

Commit

Permalink
add changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaWilkes committed Feb 8, 2024
1 parent b1d9b79 commit 260c28d
Show file tree
Hide file tree
Showing 7 changed files with 2,060 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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)

## Minor version

1. Create a new minor version changeset and merge it to main `pnpm changeset`
2. Merge the automated changesets PR `Version Packages for main` this will tag and release a new version

## Patch version

1. Create a patch changeset and merge it to main `pnpm changeset`
2. If you are ready to release this change, Merge the automated changesets PR `Version Packages for main` this will tag and release a new version

## Backporting changes to older minor versions

1. Check for an existing release branch e.g `release/v1.*` for the minor version you are back porting to
2. If the branch doesn't exist, checkout the commit associated with the minor release you want to backport to
3. Run `./create-minor-release.sh` and when prompted set the release branch version e.g `v1.1` or `v1.2` excluding the patch version
4. Push the branch
5. You can now push your changes to this release branch, you may choose to cherrypick the patch from main
6. Create a patch changeset and merge it to the release branch `pnpm changeset`
7. If you are ready to release this change, Merge the automated changesets PR matching your release branch `Version Packages for release/v1.*` this will tag and release a new version
12 changes: 12 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": { "version": false, "tag": false }
}
53 changes: 53 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Changeset and Tag Releases

on:
push:
branches:
- "main"
- "release/*"

permissions:
id-token: write
contents: write
pull-requests: write

jobs:
changeset:
name: Changeset
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: 18.12
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Run Changesets Action
id: changesets
uses: changesets/action@v1
with:
title: Version Packages for ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
if: steps.changesets.outputs.hasChangesets == 'false'
# Push a new tag when changesets have been merged.
run: |
echo publishing
pnpm changeset tag
git push --follow-tags
echo pushed tags
41 changes: 39 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
.vscode
.DS_Store
node_modules
.DS_Store

*__debug*
.env

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan

# example: *tfplan*
tfplugindocs
.env
terraform-provider-commonfate
30 changes: 30 additions & 0 deletions create-minor-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Step 1: Ask for the version
read -p "Enter the version: " version

# Step 2: Create a new git branch
branch_name="release/$version"
git checkout -b "$branch_name"

# Step 3: Replace .changesets/config.json
config_file=".changeset/config.json"
config_content='{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "release/'"$version"'",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": { "version": false, "tag": false }
}'
echo "$config_content" > "$config_file"

# Commit the changes
git add "$config_file"
git commit -m "Add changesets config for release $version"

echo "Branch '$branch_name' created with changesets config updated."
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@common-fate/sdk",
"version": "2.7.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@changesets/cli": "^2.27.1"
},
"scripts": {
"changeset": "changeset"
}
}
Loading

0 comments on commit 260c28d

Please sign in to comment.