diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8c72cd7..054337a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,17 +8,42 @@ on: jobs: publish: + name: Publish Release runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '22.x' registry-url: 'https://registry.npmjs.org' - - run: PACKAGE_NAME=$(echo "${{ github.ref }}" | sed -E "s:refs/tags/(.+)-v[^-]+$:\1:") - - run: PACKAGE_VERSION=$(echo "${{ github.ref }}" | sed -E "s:refs/tags/.+-(v.+)$:\1:") - - run: npm version $PACKAGE_VERSION --workspace packages/$PACKAGE_NAME - - run: npm install --workspace packages/$PACKAGE_NAME - - run: npm publish --workspace packages/$PACKAGE_NAME --if-present --access public + + - run: | + echo 'package_name=${{ github.ref }}' | sed -E "s:refs/tags/(.+)/v.+$:\1:" >> $GITHUB_ENV + echo 'package_version=${{ github.ref }}' | sed -E "s:refs/tags/.+/(v.+)$:\1:" >> $GITHUB_ENV + + - name: Bumping version + run: npm version ${{ env.package_version }} --workspace packages/${{ env.package_name }} + + - name: Install dependencies + run: npm install --workspace packages/${{ env.package_name }} + + - name: Publish to registry + run: npm publish --workspace packages/${{ env.package_name }} --if-present --provenance env: - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.TREEDOM_NPMJS_TOKEN }} + + - name: Commit version + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "chore: bump ${{ env.package_name }} to version ${{ env.package_version }}" || echo "No changes to commit" + + - name: Push to main + uses: ad-m/github-push-action@v0.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: main \ No newline at end of file