Skip to content

Commit 7e8fb13

Browse files
committed
fix(ci): add Rust and wasm-pack to release workflow
1 parent 20153d7 commit 7e8fb13

File tree

1 file changed

+109
-2
lines changed

1 file changed

+109
-2
lines changed

.github/workflows/release.yml

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,112 @@ on:
66

77
jobs:
88
release:
9-
uses: SylphxAI/.github/.github/workflows/release.yml@main
10-
secrets: inherit
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
actions: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: oven-sh/setup-bun@v2
20+
with:
21+
bun-version: latest
22+
23+
- name: Setup Rust
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
targets: wasm32-unknown-unknown
27+
28+
- name: Install wasm-pack
29+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
30+
31+
- name: Install dependencies
32+
run: bun install
33+
34+
- name: Build
35+
run: bun run build
36+
37+
- uses: SylphxAI/bump@main
38+
id: bump
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
npm-token: ${{ secrets.NPM_TOKEN }}
42+
43+
- name: Format release message
44+
id: message
45+
if: steps.bump.outputs.published == 'true'
46+
shell: bash
47+
env:
48+
VERSIONS: ${{ steps.bump.outputs.versions }}
49+
REPO: ${{ github.repository }}
50+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
51+
run: |
52+
[ -z "$SLACK_WEBHOOK" ] && exit 0
53+
REPO_URL="https://github.com/$REPO"
54+
REPO_NAME="${REPO#*/}"
55+
NL=$'\n'
56+
57+
if [ -n "$VERSIONS" ] && [ "$VERSIONS" != "{}" ] && [ "$VERSIONS" != "null" ]; then
58+
PKG_COUNT=$(echo "$VERSIONS" | jq 'keys | length' 2>/dev/null || echo "0")
59+
60+
if [ "$PKG_COUNT" = "1" ]; then
61+
# Single package
62+
pkg=$(echo "$VERSIONS" | jq -r 'keys[0]')
63+
ver=$(echo "$VERSIONS" | jq -r --arg p "$pkg" '.[$p]')
64+
NPM_URL="https://www.npmjs.com/package/${pkg}/v/${ver}"
65+
RELEASE_URL="${REPO_URL}/releases/tag/v${ver}"
66+
67+
MSG="📦 *${REPO_NAME}* released${NL}${NL}"
68+
MSG="${MSG}<${NPM_URL}|\`${pkg}@${ver}\`>${NL}${NL}"
69+
MSG="${MSG}<${RELEASE_URL}|GitHub Release> · <${REPO_URL}|Repository>"
70+
else
71+
# Multiple packages
72+
MSG="📦 *${REPO_NAME}* released ${PKG_COUNT} packages${NL}${NL}"
73+
74+
for pkg in $(echo "$VERSIONS" | jq -r 'keys[]'); do
75+
ver=$(echo "$VERSIONS" | jq -r --arg p "$pkg" '.[$p]')
76+
NPM_URL="https://www.npmjs.com/package/${pkg}/v/${ver}"
77+
RELEASE_URL="${REPO_URL}/releases/tag/${pkg}@${ver}"
78+
MSG="${MSG}<${NPM_URL}|\`${pkg}@${ver}\`> · <${RELEASE_URL}|release>${NL}"
79+
done
80+
81+
MSG="${MSG}${NL}<${REPO_URL}|View Repository>"
82+
fi
83+
else
84+
MSG="📦 *${REPO_NAME}* released${NL}${NL}<${REPO_URL}|View Repository>"
85+
fi
86+
87+
echo "text<<EOF" >> $GITHUB_OUTPUT
88+
echo "$MSG" >> $GITHUB_OUTPUT
89+
echo "EOF" >> $GITHUB_OUTPUT
90+
91+
- name: Send Slack notification on success
92+
if: steps.bump.outputs.published == 'true'
93+
shell: bash
94+
env:
95+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
96+
MESSAGE: ${{ steps.message.outputs.text }}
97+
run: |
98+
[ -z "$SLACK_WEBHOOK" ] && exit 0
99+
[ -z "$MESSAGE" ] && exit 0
100+
curl -s -X POST "$SLACK_WEBHOOK" \
101+
-H "Content-Type: application/json" \
102+
-d "$(jq -n --arg text "$MESSAGE" '{text: $text}')"
103+
104+
- name: Send Slack notification on failure
105+
if: failure()
106+
shell: bash
107+
env:
108+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
109+
REPO: ${{ github.repository }}
110+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
111+
run: |
112+
[ -z "$SLACK_WEBHOOK" ] && exit 0
113+
NL=$'\n'
114+
MESSAGE="❌ *Release failed*${NL}Repository: ${REPO}${NL}<${RUN_URL}|View Workflow>"
115+
curl -s -X POST "$SLACK_WEBHOOK" \
116+
-H "Content-Type: application/json" \
117+
-d "$(jq -n --arg text "$MESSAGE" '{text: $text}')"

0 commit comments

Comments
 (0)