diff --git a/.github/workflows/first-publish.yml b/.github/workflows/first-publish.yml new file mode 100644 index 00000000..c3e691c8 --- /dev/null +++ b/.github/workflows/first-publish.yml @@ -0,0 +1,49 @@ +name: First publish + +# One-off: publishes the packages that have never been on npm (cli, ingest and +# the stores), from the v0.8 release commit, with the NPM_TOKEN secret. Once +# they exist, trusted publishing can be turned on for them and this workflow +# is removed. +on: + workflow_dispatch: + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: b456c36a86183f5e2e87129ac538632fd0c2a618 + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: pnpm + registry-url: https://registry.npmjs.org + + - run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm --filter "./packages/*" build + + - name: Publish the packages that aren't on npm yet + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: 'true' + run: | + for p in ingest cli store-cloudflare store-postgres store-redis store-sqlite store-upstash-vector; do + v=$(node -p "require('./packages/$p/package.json').version") + if npm view "@chatcops/$p@$v" version >/dev/null 2>&1; then + echo "@chatcops/$p@$v is already on npm" + continue + fi + # They're private on that commit, which pnpm publish refuses. + node -e "const f='packages/$p/package.json',fs=require('fs'),j=JSON.parse(fs.readFileSync(f));delete j.private;fs.writeFileSync(f,JSON.stringify(j,null,2)+'\n')" + (cd "packages/$p" && pnpm publish --access public --no-git-checks) + done