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

πŸ”¨ Ensure we don't release workspace-based packages #3468

Merged
merged 9 commits into from
Dec 10, 2022
40 changes: 40 additions & 0 deletions .github/workflows/safe-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Safe Release

on:
pull_request:
branches:
- main
- 'next-*_*_*'
- 'fix-v*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
safe_release:
name: 'Safe release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check no package from workspace
uses: actions/github-script@v6
with:
script: |
const { promises: { readFile } } = require('fs');
const globber = await glob.create('**/package.json');
const files = await globber.glob();
for (const file of files) {
const fileContentRaw = await readFile(file);
const fileContent = JSON.parse(fileContentRaw.toString());
for (const depVersion of Object.values(fileContent.dependencies || {})) {
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
if (depVersion.startsWith('workspace:')) {
throw new Error(`Dependencies cannot start by workspace at release time, got: ${depVersion}`);
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
}
}
for (const depVersion of Object.values(fileContent.peerDependencies || {})) {
if (depVersion.startsWith('workspace:')) {
throw new Error(`Peer-Dependencies cannot start by workspace at release time, got: ${depVersion}`);
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
}
}
}