Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Dataport/polar into fix/nar…
Browse files Browse the repository at this point in the history
…rower-type
  • Loading branch information
warm-coolguy committed Feb 5, 2024
2 parents df436fa + b4dd6f3 commit 49cee51
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ jobs:
git push origin $TAG
echo "Released and tagged $TAG"
done
- run: node ./scripts/createRelease ${{ env.TAGS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions arcana.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ For these cases, this not-so-secret file denotes our not-anymore-arcane knowledg

1. Draw a dependency tree of POLAR packages with changes documented as `"unpublished"` in their respective `CHANGELOG.md` files.
2. Start with the leafs. Update the version from `"unpublished"` to the appropriate version indicated by the nature of changes. If required, change the package.json dependencies to refer to minimum versions of dependencies used.
3. Push to main. A pipeline is now running that detects the CHANGELOG change, updates the version, publishes the package to NPM, and creates a tag `@polar/[email protected]`.
4. Create new release note on GitHub. Select the previously created tag, use it as title, and copy the relevant changelog. Link to the NPM package. If it's a client, add the NPM package to the artifacts for an easier download. See previous releases for formatting of contents and artifacts.
3. Push to main. A pipeline is now running that detects the CHANGELOG change, updates the version, publishes the package to NPM, creates a tag `@polar/[email protected]`, and procudes a GitHub release.
4. If it's a client, add the NPM package to the release artifacts for an easier download. See previous releases for formatting of contents and artifacts.
5. Delete leafs from tree made in `1`. Go back to `2` until the tree is empty.

## Update process
Expand Down
326 changes: 320 additions & 6 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"test:coverage": "jest --coverage"
},
"devDependencies": {
"@actions/github": "^5.1.1",
"@babel/core": "^7.21.3",
"@babel/preset-env": "^7.20.2",
"@cyclonedx/cyclonedx-npm": "^1.7.2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
59 changes: 59 additions & 0 deletions scripts/createRelease.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const fs = require('fs')
const { getOctokit, context } = require('@actions/github')

const tags = process.argv.slice(2)
const github = getOctokit(process.env.GITHUB_TOKEN)
const { owner, repo } = context.repo

const camelize = (strings) =>
strings[0] +
strings
.slice(1)
.map((string) => string.charAt(0).toUpperCase() + string.slice(1))
.join('')

function getBody(tag) {
const [packageName, packageVersion] = tag.split('@').slice(1)
const name = packageName.split('/')[1]
const nameParts = name.split('-')
let filePath

if (nameParts[0] === 'core' || nameParts[0] === 'components') {
filePath = `./packages/${nameParts[0]}`
} else if (name === 'lib-custom-types') {
filePath = `./packages/types/custom`
} else if (nameParts[0] === 'plugin' || nameParts[0] === 'client') {
filePath = `./packages/${nameParts[0]}s/${camelize(nameParts.slice(1))}`
} else if (nameParts[0] === 'lib') {
filePath = `./packages/${nameParts[0]}/${camelize(nameParts.slice(1))}`
} else {
const message = `Unknown package name in tag ${tag}.`
console.error(message)
process.exit = 1
throw new Error(message)
}
const data = fs.readFileSync(`${filePath}/CHANGELOG.md`, { encoding: 'utf8' })
return `## CHANGELOG
${data
.split('##')[1]
.split('\n')
.slice(1)
.join(
'\n'
)}[NPM package](https://www.npmjs.com/package/${packageName}/v/${packageVersion})`
}

for (const tag of tags) {
github.request(`POST /repos/${owner}/${repo}/releases`, {
owner,
repo,
tag_name: tag,
name: tag,
body: getBody(tag),
headers: {
'X-GitHub-Api-Version': '2022-11-28',
},
})
}

0 comments on commit 49cee51

Please sign in to comment.