feat: change sofia_pink #2871
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Prerelease | |
on: | |
push: | |
branches-ignore: | |
- "master" | |
jobs: | |
build: | |
name: Build | |
if: "contains(github.event.head_commit.message, '[prerelease]')" | |
uses: ./.github/workflows/build-and-upload.yml | |
secrets: | |
npm_token: ${{ secrets.npm_token }} | |
prerelease: | |
name: Prerelease | |
needs: build | |
if: ${{ needs.build.outputs.has_changes == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run Setup | |
uses: ./.github/actions/setup | |
with: | |
npm_token: ${{ secrets.npm_token }} | |
- uses: ./.github/actions/git-creds | |
- uses: ./.github/actions/download-builds | |
- name: Generate new versions | |
id: generate-versions | |
run: | | |
preid=${{ github.ref_name }} | |
normalized_pre_id=$(echo "$preid" | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]') | |
full_output=$(yarn lerna version --exact --conventional-commits --conventional-prerelease --json --no-changelog --no-push --preid "$normalized_pre_id" -y) | |
# extract only the JSON portion from the full output, excluding yarn logs | |
json_output=$(echo "$full_output" | awk '/^\[/{p=1} p; /\]/{p=0}' ) | |
echo 'new_versions<<EOF' >> $GITHUB_OUTPUT | |
echo "$json_output" >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
- run: yarn config set registry https://registry.npmjs.org/ | |
- name: Setup .npmrc for publish | |
run: npm set "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.npm_token }} | |
- name: Publish new versions | |
run: yarn lerna publish from-package --dist-tag prerelease -y | |
- name: Get current PR id | |
uses: 8BitJonny/[email protected] | |
id: PR | |
- name: Prepare PR comment | |
id: prepare-comment | |
env: | |
json_data: ${{ steps.generate-versions.outputs.new_versions }} | |
run: | | |
echo 'comment_body<<EOF' >> $GITHUB_OUTPUT | |
echo "A new prerelease version of this PR has been published! 🎉" >> $GITHUB_OUTPUT | |
echo "To install this prerelease version, run the following command in your terminal with any one of the packages changed in this PR:" >> $GITHUB_OUTPUT | |
echo "$json_data" | jq -r '.[] | "\nTo update `\(.name)`:\n```\nyarn add \(.name)@\(.newVersion)\n```\nOr with npm:\n```\nnpm i \(.name)@\(.newVersion)\n```\n"' >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
- name: Create comment with prerelease version details | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ steps.PR.outputs.number }} | |
body: ${{ steps.prepare-comment.outputs.comment_body }} |