-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds canary.yml * release:canary * dependencies * pnpm-lock.yaml * pnpm install --no-frozen-lockfile * shared-workspace-lockfile * pnpm i * pnpm up * Remove duplicat step * changeset config * GITHUB_TOKEN * pnpm up not working * don't install pnpm twice * setup npm credentials * Delete cuddly-beans-approve.md Co-authored-by: Pablo Sáez <[email protected]>
- Loading branch information
Showing
6 changed files
with
149 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Canary Release | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
publish-canary: | ||
name: Publish Canary | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@master | ||
with: | ||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | ||
fetch-depth: 0 | ||
|
||
- name: Setup PNPM | ||
uses: pnpm/[email protected] | ||
with: | ||
version: ^7.9.5 | ||
|
||
- name: Use Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
cache: 'pnpm' | ||
|
||
- name: Setup NPM credentials | ||
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Install Dependencies | ||
run: pnpm i | ||
|
||
- name: Release Canary | ||
id: canary | ||
uses: 'kamilkisiela/release-canary@master' | ||
with: | ||
npm-token: ${{ secrets.NPM_TOKEN }} | ||
npm-script: 'pnpm release:canary' | ||
changesets: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
strict-peer-dependencies=false | ||
shared-workspace-lockfile=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"postinstall": "husky install", | ||
"pretty-quick": "pretty-quick --staged", | ||
"release": "pnpm -r --access=public publish --no-git-checks", | ||
"release:canary": "(node scripts/canary-release.js && pnpm -r publish --access public --no-git-checks --tag alpha) || echo Skipping Canary...", | ||
"test": "pnpm -r --filter=sdk test", | ||
"tsc": "tsc -p tsconfig.check.json", | ||
"changeset": "changeset" | ||
|
@@ -31,8 +32,13 @@ | |
], | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
"@changesets/apply-release-plan": "^6.1.0", | ||
"@changesets/assemble-release-plan": "^5.2.1", | ||
"@changesets/changelog-github": "0.4.6", | ||
"@changesets/cli": "2.24.3", | ||
"@changesets/config": "^2.1.1", | ||
"@changesets/read": "^0.5.7", | ||
"@manypkg/get-packages": "^1.1.3", | ||
"@types/node": "18.7.5", | ||
"@typescript-eslint/eslint-plugin": "^5.36.1", | ||
"@typescript-eslint/parser": "^5.36.1", | ||
|
@@ -44,6 +50,7 @@ | |
"prettier": "^2.7.1", | ||
"pretty-quick": "^3.1.3", | ||
"rimraf": "^3.0.2", | ||
"semver": "^7.3.7", | ||
"typescript": "4.7.4" | ||
}, | ||
"pnpm": { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const semver = require('semver') | ||
const cp = require('child_process') | ||
const { basename } = require('path') | ||
|
||
const { read: readConfig } = require('@changesets/config') | ||
const readChangesets = require('@changesets/read').default | ||
const assembleReleasePlan = require('@changesets/assemble-release-plan').default | ||
const applyReleasePlan = require('@changesets/apply-release-plan').default | ||
const { getPackages } = require('@manypkg/get-packages') | ||
|
||
function getNewVersion(version, type) { | ||
const gitHash = cp.spawnSync('git', ['rev-parse', '--short', 'HEAD']).stdout.toString().trim() | ||
|
||
return semver.inc(version, `pre${type}`, true, 'alpha-' + gitHash) | ||
} | ||
|
||
function getRelevantChangesets(baseBranch) { | ||
const comparePoint = cp | ||
.spawnSync('git', ['merge-base', `origin/${baseBranch}`, 'HEAD']) | ||
.stdout.toString() | ||
.trim() | ||
console.log('compare point', comparePoint) | ||
const listModifiedFiles = cp | ||
.spawnSync('git', ['diff', '--name-only', comparePoint]) | ||
.stdout.toString() | ||
.trim() | ||
.split('\n') | ||
console.log('listModifiedFiles', listModifiedFiles) | ||
|
||
const items = listModifiedFiles.filter((f) => f.startsWith('.changeset')).map((f) => basename(f, '.md')) | ||
console.log('items', items) | ||
|
||
return items | ||
} | ||
|
||
async function updateVersions() { | ||
const cwd = process.cwd() | ||
const packages = await getPackages(cwd) | ||
const config = await readConfig(cwd, packages) | ||
const modifiedChangesets = getRelevantChangesets(config.baseBranch) | ||
const changesets = (await readChangesets(cwd)).filter((change) => modifiedChangesets.includes(change.id)) | ||
|
||
if (changesets.length === 0) { | ||
console.warn(`Unable to find any relevant package for canary publishing. Please make sure changesets exists!`) | ||
process.exit(1) | ||
} else { | ||
const releasePlan = assembleReleasePlan(changesets, packages, config, undefined, false) | ||
|
||
if (releasePlan.releases.length === 0) { | ||
console.warn(`Unable to find any relevant package for canary releasing. Please make sure changesets exists!`) | ||
process.exit(1) | ||
} else { | ||
for (const release of releasePlan.releases) { | ||
if (release.type !== 'none') { | ||
release.newVersion = getNewVersion(release.oldVersion, release.type) | ||
} | ||
} | ||
|
||
await applyReleasePlan( | ||
releasePlan, | ||
packages, | ||
{ | ||
...config, | ||
commit: false, | ||
}, | ||
false, | ||
true, | ||
) | ||
} | ||
} | ||
} | ||
|
||
updateVersions() | ||
.then(() => { | ||
console.info(`Done!`) | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |