diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000..6460fed --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,12 @@ +{ + "mode": "pre", + "tag": "alpha", + "initialVersions": { + "@ts-contract/docs": "0.0.0", + "@ts-contract/core": "0.0.1", + "@ts-contract/plugins": "0.0.1" + }, + "changesets": [ + "upset-eyes-brush" + ] +} diff --git a/.changeset/upset-eyes-brush.md b/.changeset/upset-eyes-brush.md new file mode 100644 index 0000000..7e0283a --- /dev/null +++ b/.changeset/upset-eyes-brush.md @@ -0,0 +1,6 @@ +--- +'@ts-contract/core': major +'@ts-contract/plugins': major +--- + +First alpha release of ts-contract - schema-first TypeScript contract library with core contract definitions and built-in plugins for path building and validation diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e90fe0b..e036fd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,8 +54,57 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Create GitHub Release + - name: Create GitHub Releases if: steps.changesets.outputs.published == 'true' - run: | - echo "Packages published:" - echo "${{ steps.changesets.outputs.publishedPackages }}" + uses: actions/github-script@v7 + with: + script: | + const publishedPackages = JSON.parse('${{ steps.changesets.outputs.publishedPackages }}'); + + for (const pkg of publishedPackages) { + const tagName = `${pkg.name}@${pkg.version}`; + const releaseName = `${pkg.name} v${pkg.version}`; + + // Read the changelog for this package + const fs = require('fs'); + const path = require('path'); + + let changelogPath; + if (pkg.name === '@ts-contract/core') { + changelogPath = 'packages/core/CHANGELOG.md'; + } else if (pkg.name === '@ts-contract/plugins') { + changelogPath = 'packages/plugins/CHANGELOG.md'; + } + + let releaseNotes = `Release of ${pkg.name} version ${pkg.version}`; + + if (changelogPath && fs.existsSync(changelogPath)) { + const changelog = fs.readFileSync(changelogPath, 'utf8'); + // Extract the latest version's notes + const versionHeader = `## ${pkg.version}`; + const startIndex = changelog.indexOf(versionHeader); + if (startIndex !== -1) { + const afterHeader = changelog.slice(startIndex + versionHeader.length); + const nextVersionIndex = afterHeader.indexOf('\n## '); + const notes = nextVersionIndex !== -1 + ? afterHeader.slice(0, nextVersionIndex) + : afterHeader; + releaseNotes = notes.trim(); + } + } + + try { + await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: tagName, + name: releaseName, + body: releaseNotes, + prerelease: pkg.version.includes('-alpha') || pkg.version.includes('-beta'), + draft: false + }); + console.log(`Created release for ${tagName}`); + } catch (error) { + console.error(`Failed to create release for ${tagName}:`, error.message); + } + } diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md new file mode 100644 index 0000000..94f01ba --- /dev/null +++ b/packages/core/CHANGELOG.md @@ -0,0 +1,7 @@ +# @ts-contract/core + +## 1.0.0-alpha.0 + +### Major Changes + +- First alpha release of ts-contract - schema-first TypeScript contract library with core contract definitions and built-in plugins for path building and validation diff --git a/packages/core/package.json b/packages/core/package.json index a972f41..a9ef4dc 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@ts-contract/core", - "version": "0.0.1", + "version": "1.0.0-alpha.0", "description": "Contract definitions, type inference helpers, and plugin system for ts-contract", "type": "module", "main": "./dist/index.js", diff --git a/packages/plugins/CHANGELOG.md b/packages/plugins/CHANGELOG.md new file mode 100644 index 0000000..684c267 --- /dev/null +++ b/packages/plugins/CHANGELOG.md @@ -0,0 +1,12 @@ +# @ts-contract/plugins + +## 1.0.0-alpha.0 + +### Major Changes + +- First alpha release of ts-contract - schema-first TypeScript contract library with core contract definitions and built-in plugins for path building and validation + +### Patch Changes + +- Updated dependencies + - @ts-contract/core@1.0.0-alpha.0 diff --git a/packages/plugins/package.json b/packages/plugins/package.json index bacfce0..9f05a9c 100644 --- a/packages/plugins/package.json +++ b/packages/plugins/package.json @@ -1,6 +1,6 @@ { "name": "@ts-contract/plugins", - "version": "0.0.1", + "version": "1.0.0-alpha.0", "description": "Built-in plugins for path building and schema validation for ts-contract", "type": "module", "main": "./dist/index.js",