diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index dfa9e0215..4f055ec8e 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -8,6 +8,8 @@ on: jobs: publish: runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.TAGS }} steps: - uses: actions/checkout@v2 with: @@ -17,10 +19,19 @@ jobs: node-version: 18.13.0 registry-url: https://registry.npmjs.org/ - run: npm ci - - run: npm run publishPackages + - run: echo "TAGS=$(node ./scripts/publishPackages)" >> $GITHUB_ENV env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - uses: EndBug/add-and-commit@v9 with: author_name: Dataport Geo Bot author_email: dataportpolarsupport@dataport.de + - run: | + for TAG in ${{ env.TAGS }} + do + git config user.name "Dataport Geo Bot" + git config user.email "dataportpolarsupport@dataport.de" + git tag $TAG + git push origin $TAG + echo "Released and tagged $TAG" + done diff --git a/.hack.sh.swp b/.hack.sh.swp new file mode 100644 index 000000000..aca63ec09 Binary files /dev/null and b/.hack.sh.swp differ diff --git a/arcana.md b/arcana.md index 929c28b93..7ac76cf88 100644 --- a/arcana.md +++ b/arcana.md @@ -8,10 +8,9 @@ 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, and publishes the package to NPM. -4. Pull. Tag the last commit with `git tag @polar/package-name@x.y.z` appropriately for all packages released in that commit. `git push --tags` to push tags to GitHub. -5. 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. -6. Delete leafs from tree made in `1`. Go back to `2` until the tree is empty. +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/package-name@x.y.z`. +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. +5. Delete leafs from tree made in `1`. Go back to `2` until the tree is empty. ## Update process diff --git a/scripts/publishPackages.js b/scripts/publishPackages.js index 00f0a27c4..25db8ff2d 100644 --- a/scripts/publishPackages.js +++ b/scripts/publishPackages.js @@ -6,6 +6,8 @@ const cp = require('child_process') const fs = require('fs') const packages = require('./packages') +const tags = [] + function checkForNewVersion(cwd) { const { version } = JSON.parse( fs.readFileSync(cwd + '/package.json', { encoding: 'UTF-8' }) @@ -18,6 +20,13 @@ function checkForNewVersion(cwd) { } } +function getPackageName(cwd) { + const { name } = JSON.parse( + fs.readFileSync(cwd + '/package.json', { encoding: 'UTF-8' }) + ) + return name +} + for (const path of packages) { try { const nextVersion = checkForNewVersion(path) @@ -30,12 +39,12 @@ for (const path of packages) { { cwd: path } ) cp.execSync('npm publish --access=public', context) - console.info(`The package in '${path}' was published as v${nextVersion}.`) - } else { - console.info("No update in '" + path + "'.") + tags.push(`${getPackageName(path)}@${nextVersion}`) } } catch (e) { console.error(e) process.exitCode = 1 } } + +process.stdout.write(tags.join(' '))