diff --git a/.changeset/flat-dodos-crash.md b/.changeset/flat-dodos-crash.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/flat-dodos-crash.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml new file mode 100644 index 00000000000..7d41d291a39 --- /dev/null +++ b/.github/workflows/rc-release.yaml @@ -0,0 +1,58 @@ +name: Release to @rc- tag on npm + +on: + push: + branches: + - "rc/*" + +jobs: + release-pr: + name: "Release RC to npm" + runs-on: ubuntu-latest + permissions: write-all + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + + - name: CI Setup + uses: ./.github/actions/ci-setup + + - name: Ensure NPM access + run: npm whoami + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Build + run: pnpm build + + - name: Get RC name + uses: frabert/replace-string-action@v2 + id: rc_name + with: + string: ${{ github.ref }} + pattern: "rc/" + replace-with: "rc-" + + - name: Release to @${{ steps.rc_name.outputs.replaced }} tag on npm + id: release + run: | + echo "${{ steps.rc_name.outputs.replaced }}" + pnpm changeset:next + git add .changeset/fuel-labs-ci.md + pnpm changeset version --snapshot ${{ steps.rc_name.outputs.replaced }} + changetsets=$(pnpm changeset publish --tag ${{ steps.rc_name.outputs.replaced }}) + published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ steps.rc_name.outputs.replaced }}-\d+' | head -1) + echo "published_version=$published_version" >> $GITHUB_OUTPUT + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: mshick/add-pr-comment@v2 + with: + message: | + This RC is published in NPM with version **${{ steps.rc_name.outputs.replaced }}** + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}