-
Notifications
You must be signed in to change notification settings - Fork 8
146 lines (129 loc) · 5.01 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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 }}