Skip to content

Commit a39697a

Browse files
authored
setup wagmi integration deployment pipeline (#65)
* setup wagmi integration deployment pipeline * remove unnecessary homepage check
1 parent a348202 commit a39697a

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy Wagmi Integration to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
destination_dir:
7+
required: true
8+
type: string
9+
secrets:
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
12+
workflow_dispatch:
13+
inputs:
14+
destination_dir:
15+
description: 'Destination directory on GitHub Pages (e.g., "latest", "5.0.0", "wagmi")'
16+
required: true
17+
type: string
18+
19+
jobs:
20+
deploy-wagmi-to-gh-pages:
21+
name: Deploy Wagmi Integration to GitHub Pages
22+
runs-on: ubuntu-latest
23+
environment: gh-pages
24+
permissions:
25+
contents: write
26+
27+
steps:
28+
- name: Ensure `destination_dir` is not empty
29+
if: ${{ inputs.destination_dir == '' }}
30+
run: exit 1
31+
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Corepack via Node
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version-file: '.nvmrc'
38+
39+
- name: Install Yarn
40+
run: corepack enable
41+
42+
- name: Restore Yarn cache
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version-file: '.nvmrc'
46+
cache: 'yarn'
47+
48+
- name: Install dependencies via Yarn
49+
run: yarn --immutable
50+
51+
- name: Build workspace dependencies
52+
run: |
53+
# Build all packages (workspace dependencies) in topological order
54+
# This ensures @metamask/connect-evm and other dependencies are built first
55+
yarn workspaces foreach --all --topological-dev --verbose --no-private run build
56+
57+
- name: Build wagmi integration
58+
working-directory: integrations/wagmi
59+
env:
60+
VITE_BASE_PATH: /${{ inputs.destination_dir }}/
61+
run: yarn build
62+
63+
- name: Deploy to `${{ inputs.destination_dir }}` directory of `gh-pages` branch
64+
uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935
65+
with:
66+
# This `PUBLISH_DOCS_TOKEN` needs to be manually set per-repository.
67+
# Look in the repository settings under "Environments", and set this token in the `github-pages` environment.
68+
personal_token: ${{ secrets.PUBLISH_DOCS_TOKEN }}
69+
publish_dir: ./integrations/wagmi/dist
70+
destination_dir: ${{ inputs.destination_dir }}
71+

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
secrets:
6464
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6565
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
66+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
6667

6768
all-jobs-complete:
6869
name: All jobs complete

.github/workflows/publish-release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
required: true
88
SLACK_WEBHOOK_URL:
99
required: true
10+
PUBLISH_DOCS_TOKEN:
11+
required: true
1012

1113
jobs:
1214
publish-release:
@@ -71,3 +73,48 @@ jobs:
7173
uses: MetaMask/action-npm-publish@v5
7274
with:
7375
npm-token: ${{ secrets.NPM_TOKEN }}
76+
77+
get-release-version:
78+
needs: publish-npm
79+
runs-on: ubuntu-latest
80+
outputs:
81+
RELEASE_VERSION: ${{ steps.get-release-version.outputs.RELEASE_VERSION }}
82+
steps:
83+
- uses: actions/checkout@v4
84+
with:
85+
ref: ${{ github.sha }}
86+
fetch-depth: 0
87+
- id: get-release-version
88+
shell: bash
89+
run: |
90+
# Get version from the latest git tag created by the release action
91+
VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
92+
if [ -z "$VERSION" ]; then
93+
# Fallback to package.json version if no tag found
94+
VERSION=$(node -p "require('./package.json').version")
95+
fi
96+
# Remove 'v' prefix if present
97+
VERSION=${VERSION#v}
98+
echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_OUTPUT"
99+
100+
publish-wagmi-to-gh-pages:
101+
name: Publish Wagmi Integration to `${{ needs.get-release-version.outputs.RELEASE_VERSION }}` directory of `gh-pages` branch
102+
needs: get-release-version
103+
permissions:
104+
contents: write
105+
uses: ./.github/workflows/deploy-wagmi-to-gh-pages.yml
106+
with:
107+
destination_dir: ${{ needs.get-release-version.outputs.RELEASE_VERSION }}
108+
secrets:
109+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}
110+
111+
publish-wagmi-to-latest-gh-pages:
112+
name: Publish Wagmi Integration to `latest` directory of `gh-pages` branch
113+
needs: publish-npm
114+
permissions:
115+
contents: write
116+
uses: ./.github/workflows/deploy-wagmi-to-gh-pages.yml
117+
with:
118+
destination_dir: latest
119+
secrets:
120+
PUBLISH_DOCS_TOKEN: ${{ secrets.PUBLISH_DOCS_TOKEN }}

integrations/wagmi/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import { defineConfig } from 'vite'
44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7+
base: process.env.VITE_BASE_PATH || '/',
78
})

0 commit comments

Comments
 (0)