Skip to content

Version Packages (#321) #241

Version Packages (#321)

Version Packages (#321) #241

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions: {} #reset
env:
CI: true
RELEASE: true
jobs:
release:
# prevent this action from running on forks
if: github.repository == 'pluto-lang/pluto'
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
name: Release
runs-on: ubuntu-latest
outputs:
published: ${{ steps.changesets.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
cliPublished: ${{ steps.check-cli-publish.outputs.published }}
steps:
- name: Install Graphviz
run: sudo apt-get install -y graphviz
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup PNPM
uses: pnpm/action-setup@v4
- name: Prepare dependent packages
run: bash scripts/prepare.sh
- name: Install Dependencies
run: pnpm install && pip install -r requirements.txt
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Check if @plutolang/cli is published
if: steps.changesets.outputs.published == 'true'
id: check-cli-publish
run: |
if [[ "${RELEASE_PACKAGES}" == *"@plutolang/cli"* ]]; then
echo "@plutolang/cli is published!"
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "@plutolang/cli is not published!"
echo "published=false" >> "$GITHUB_OUTPUT"
fi
env:
RELEASE_PACKAGES: ${{ toJSON(steps.changesets.outputs.publishedPackages) }}
send-slack-message:
name: Send Slack Message
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Construct Slack Message
id: construct-slack-message
run: |
MESSAGE="$(node scripts/construct-slack-message.js)"
echo $MESSAGE
echo "message=$MESSAGE" >> "$GITHUB_OUTPUT"
env:
RELEASE_PACKAGES: ${{ needs.release.outputs.publishedPackages }}
COMMIT_URL: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}
- name: Send a Slack notification if a publish happens
uses: slackapi/slack-github-action@v1.24.0
with:
channel-id: "C0625J88DNY"
payload: ${{ steps.construct-slack-message.outputs.message }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
trigger-build-docker-images:
name: Trigger Build Docker Images
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
steps:
- name: Trigger to build docker images
run: |
version=$(echo "${RELEASE_PACKAGES}" | jq -r '.[] | select(.name == "@plutolang/cli") | .version')
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/pluto-lang/pluto/dispatches" \
-d '{ "event_type": "trigger-build-docker-images", "client_payload": { "version": "'${version}'" } }'
env:
GITHUB_TOKEN: ${{ secrets.PLUTO_WORKFLOW_GITHUB_TOKEN_JIANZS }}
RELEASE_PACKAGES: ${{ needs.release.outputs.publishedPackages }}
trigger-bump-pluto-codesandbox:
name: Trigger Bump Pluto in Codesandbox
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
steps:
- name: Trigger to bump pluto version in codesandbox
run: |
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/pluto-lang/codesandbox/dispatches" \
-d '{ "event_type": "trigger-bump-pluto", "client_payload": { "packages": '${RELEASE_PACKAGES}' } }'
env:
GITHUB_TOKEN: ${{ secrets.PLUTO_WORKFLOW_GITHUB_TOKEN_JIANZS }}
RELEASE_PACKAGES: ${{ needs.release.outputs.publishedPackages }}