Skip to content

Commit

Permalink
Setup changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Nov 3, 2023
1 parent c6ca822 commit 68136ce
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-shoes-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ny": patch
---

Fix handling of `--help` argument passed to scripts
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/config@2.3.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": [],
"privatePackages": { "version": true, "tag": true }
}
5 changes: 5 additions & 0 deletions .changeset/great-beans-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ny": patch
---

Gracefully skip not existing `@types` packages
19 changes: 19 additions & 0 deletions .changeset/sync-cargo-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Syncs version stored in package.json (which is managed by changesets) with version stored in Cargo.toml
*/
import { writeFileSync, readFileSync } from "fs";
import { join } from "path";

function rewriteVersionInCargoConfig(config: string, newVersion: string) {
const regex = /version = "(\d+\.\d+\.\d+)"/; // note: no global flag -- we want to replace the first instance only
return config.replace(regex, `version = "${newVersion}"`);
}

const currentVersion = require("../package.json").version;
console.log(`Syncing Cargo.toml version to ${currentVersion}`);

const cargoConfigRaw = readFileSync(join(__dirname, "../Cargo.toml"), "utf-8");

const newCargoConfig = rewriteVersionInCargoConfig(cargoConfigRaw, currentVersion);

writeFileSync(join(__dirname, "../Cargo.toml"), newCargoConfig);
23 changes: 23 additions & 0 deletions .github/workflows/changesets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Changesets

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: oven-sh/setup-bun@v1

- run: bun install

- name: Create Release Pull Request or Start release (tag)
uses: changesets/action@v1
with:
version: bun version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
node_modules
Binary file added bun.lockb
Binary file not shown.
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "ny",
"private": true,
"version": "0.1.2",
"dependencies": {
"@changesets/cli": "^2.26.2"
},
"scripts": {
"version": "changesets version && bun .changesets/sync-cargo-version.ts"
}
}

0 comments on commit 68136ce

Please sign in to comment.