From a6150f8f892615525fdf6c70dfd9292d234b86c4 Mon Sep 17 00:00:00 2001 From: Benjamin Schmidt Date: Tue, 23 Jul 2024 17:31:52 -0400 Subject: [PATCH] ci: adding publish script (#55) * adding publish script * update prerelease workflow * change node version in workflow * Update .github/workflows/npm-publish.yml Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --------- Co-authored-by: Robert Lesser Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- .github/workflows/npm-publish.yml | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..e457706 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,44 @@ +name: Publish Next Tag Version + +on: + push: + branches: + - main + +jobs: + publish-next-tag-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org' + + - name: Install release-please + run: npm install -g release-please + + - name: Determine next version and update package.json + run: | + # Determine next version + OUTPUT=$(release-please release-pr --dry-run --token=${{ secrets.GITHUB_TOKEN }} --repo-url=${{ github.repository }} --default-branch=main) + NEXT_VERSION=$(echo "$OUTPUT" | grep "chore(main): release atlas" | sed 's/.*atlas //') + echo "Next version: $NEXT_VERSION" + + # Count existing pre-releases + NEXT_VERSION_COUNT=$(npm view . versions --json | jq "[.[] | select(startswith(\"$NEXT_VERSION-next.\"))] | length") + echo "Number of existing pre-releases: $NEXT_VERSION_COUNT" + + # Create final version string + FINAL_VERSION="${NEXT_VERSION}-next.${NEXT_VERSION_COUNT}" + echo "Final version: $FINAL_VERSION" + + # Update package.json + npm version $FINAL_VERSION --no-git-tag-version + npm publish --preid=next + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}