Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .github/workflows/publish-latest.yml

This file was deleted.

98 changes: 98 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Publish

permissions:
id-token: write

on:
push:
branches:
- main
paths:
- '**/package.json'
pull_request:
branches:
- main
paths:
- '**/package.json'

jobs:
dry-run:
if: github.event_name == 'pull_request'
name: Typir Publish (dry run)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use MISE config to install the required Node version
uses: jdx/mise-action@v4
with:
version: v2026.8.16

- name: Build
shell: bash
run: |
npm i -g npm
npm ci
npm run clean
npm run build

- name: Check dependencies
shell: bash
run: |
npm run version:check-dependencies

- name: Test
if: success() || failure()
shell: bash
run: |
npm run test:run

- name: Publish (dry run)
uses: TypeFox/gh-publish-npm@7183224bef010236e419a2367208633ff284337a # v0.5.0
with:
dry-run: true
npm-packages: |
packages/typir
packages/typir-langium

publish:
if: github.event_name != 'pull_request'
name: Typir Publish
runs-on: ubuntu-latest
environment: publish
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use MISE config to install the required Node version
uses: jdx/mise-action@v4
with:
version: v2026.8.16

- name: Build
shell: bash
run: |
npm i -g npm
npm ci
npm run clean
npm run build

- name: Check dependencies
shell: bash
run: |
npm run version:check-dependencies

- name: Test
if: success() || failure()
shell: bash
run: |
npm run test:run

- name: Publish
uses: TypeFox/gh-publish-npm@7183224bef010236e419a2367208633ff284337a # v0.5.0
with:
dry-run: false
npm-packages: |
packages/typir
packages/typir-langium
11 changes: 5 additions & 6 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Release Process

## `latest` releases

The release process is mostly automated and requires running only a few commands. After commiting, pushing, tagging and releasing the changes, a GitHub Action will publish all npm packages.
The release process is mostly automated and requires running only a few commands. After commiting, pushing the changes to `main`, a GitHub Action will publish all npm packages. But only if `package.json` files are updated in their version field.

1. Pull the latest changes from the main branch
2. Create a new branch
3. Uplift the package versions by running `npm version major|minor|patch --no-git-tag-version --workspaces`
4. Update the dependency versions by running `npm run version:dependencies`
5. Create a PR with your updated changes, get a review and merge it
6. Create a version tag on the latest commit on main and push it
6. The publish process will be triggered automatically when the `package.json` files are updated
* when making changes in the scope of a PR, the publish process will be executed in dry-run mode
* when the changes are merged into the main branch, the NPM packages will be published automatically
7. (optional) Create a version tag on the latest commit on main and push it

```bash
git checkout main
git pull origin main
git tag <version-tag>
git push origin <version-tag>
```

7. Create a [GitHub release](https://github.com/TypeFox/typir/releases) from the new tag (this will trigger the Github Action and publish all artifacts automatically).
30 changes: 0 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"langium:watch": "npm run langium:watch --workspace=examples/ox --workspace=examples/lox",
"vscode:prepublish": "npm run build && npm run lint",
"reset:repo": "git clean -f -d -x",
"version:dependencies": "node ./scripts/update-version.js && npm install"
"version:dependencies": "node ./scripts/update-version.js && npm install",
"version:check-dependencies": "node ./scripts/check-versions.js"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
Expand Down
5 changes: 1 addition & 4 deletions packages/typir-langium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
"clean": "shx rm -rf lib out *.tsbuildinfo",
"build": "tsc",
"watch": "tsc --watch",
"lint": "eslint src --ext .ts",
"version:next": "npm --no-git-tag-version version \"$(semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\"",
"publish:latest": "npm publish --tag latest --access public",
"publish:next": "npm publish --tag next"
"lint": "eslint src --ext .ts"
},
"repository": {
"type": "git",
Expand Down
5 changes: 1 addition & 4 deletions packages/typir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
"clean": "shx rm -rf lib out *.tsbuildinfo",
"build": "tsc",
"watch": "tsc --watch",
"lint": "eslint src test --ext .ts",
"version:next": "npm --no-git-tag-version version \"$(npx semver $npm_package_version -i minor)-next.$(git rev-parse --short HEAD)\"",
"publish:latest": "npm publish --tag latest --access public",
"publish:next": "npm publish --tag next"
"lint": "eslint src test --ext .ts"
},
"repository": {
"type": "git",
Expand Down
40 changes: 40 additions & 0 deletions scripts/check-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from 'fs-extra';
import { getVersionOf, getPath } from './shared.js';

async function runCheck() {
const versions = await Promise.all([
getVersionOf('typir'),
getVersionOf('typir-langium'),
]);
const successes = await Promise.all([
checkAll('typir', true, versions),
checkAll('typir-langium', true, versions),
checkAll('expression', false, versions),
checkAll('ox', false, versions),
checkAll('lox', false, versions),
]);
return successes.reduce((acc, curr) => acc && curr, true);
}

async function checkAll(project, pkg, versions) {
const path = getPath(project, pkg);
const manifest = await fs.readJson(path);
let success = true;
for (const [dependency, version] of versions) {
for (const section of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
const declared = manifest[section]?.[dependency];
if (declared !== undefined) {
const actual = declared.replace(/^[~^]/, '');
if (actual !== version) {
console.log(`Version mismatch for ${dependency}: expected ${version}, found ${actual} !`);
success = false;
}
}
}
}
return success;
}

if(!await runCheck()) {
process.exit(1);
}
11 changes: 11 additions & 0 deletions scripts/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fs from 'fs-extra';
import path from 'node:path';

export function getPath(project, pkg) {
return path.join(pkg ? 'packages' : 'examples', project, 'package.json');
}
export async function getVersionOf(project) {
const typirPath = getPath(project, true);
const typirPackage = await fs.readJson(typirPath);
return [project, typirPackage.version];
}
14 changes: 2 additions & 12 deletions scripts/update-version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import path from 'path';
import { getVersionOf, getPath } from './shared.js';

async function runUpdate() {
const versions = await Promise.all([
Expand All @@ -19,20 +19,10 @@ async function replaceAll(project, pkg, versions) {
const path = getPath(project, pkg);
let content = await fs.readFile(path, 'utf-8');
versions.forEach(([project, version]) => {
const regex = new RegExp("(?<=\"" + project + "\": \"[~\\^]?)\\d+\\.\\d+\\.\\d+", "g");
const regex = new RegExp("(?<=\"" + project + "\": *\"[~\\^]?)\\d+\\.\\d+\\.\\d+", "g");
content = content.replace(regex, version);
});
await fs.writeFile(path, content);
}

function getPath(project, pkg) {
return path.join(pkg ? 'packages' : 'examples', project, 'package.json');
}

async function getVersionOf(project) {
const typirPath = getPath(project, true);
const typirPackage = await fs.readJson(typirPath);
return [project, typirPackage.version];
}

runUpdate();
Loading