Skip to content

Commit 809f274

Browse files
committed
chore: add CI workflow for contracts sync and release process
1 parent 5500bd2 commit 809f274

2 files changed

Lines changed: 88 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
checks: write
13+
14+
jobs:
15+
build-test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 10
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: 'pnpm'
31+
32+
- name: Setup Bun (runtime for scripts/tests)
33+
uses: oven-sh/setup-bun@v2
34+
with:
35+
bun-version: latest
36+
37+
- name: Install Dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Type Check
41+
run: pnpm run typecheck
42+
43+
- name: Build
44+
run: pnpm run build
45+
46+
- name: Format Check (Biome)
47+
run: pnpm run format:check
48+
49+
- name: Run Tests
50+
run: pnpm test
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Automated contract update and publish
1+
name: Contracts Sync & Release
22

33
on:
44
workflow_dispatch:
55
inputs:
66
release_type:
7-
description: "Version increment type"
7+
description: "Version bump type (patch | minor | major | prerelease)"
88
required: true
99
type: choice
1010
default: patch
@@ -14,7 +14,7 @@ on:
1414
- major
1515
- prerelease
1616
preid:
17-
description: "Pre-release identifier (e.g., rc, beta) used only when release_type=prerelease"
17+
description: "Pre-release identifier (e.g., rc, beta) - used only when release_type=prerelease"
1818
required: false
1919
type: string
2020

@@ -24,105 +24,106 @@ permissions:
2424

2525
jobs:
2626
update-and-publish:
27+
name: Update Contracts & Publish Package
2728
runs-on: ubuntu-latest
2829
steps:
29-
- uses: actions/checkout@v4
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
3032
with:
3133
fetch-depth: 0
3234
token: ${{ secrets.PAT }}
3335

34-
- name: Install pnpm
36+
- name: Setup pnpm
3537
uses: pnpm/action-setup@v4
3638
with:
3739
version: 10
3840

39-
- name: Setup Node.js
41+
- name: Setup Node.js (npm registry)
4042
uses: actions/setup-node@v4
4143
with:
42-
node-version: "20"
43-
registry-url: "https://registry.npmjs.org/"
44-
cache: 'pnpm'
44+
node-version: '20'
45+
registry-url: 'https://registry.npmjs.org/'
46+
cache: pnpm
4547

4648
- name: Setup Bun
4749
uses: oven-sh/setup-bun@v2
4850
with:
4951
bun-version: latest
5052

51-
- name: Install Dependencies
53+
- name: Install Dependencies (pnpm)
5254
run: pnpm install --frozen-lockfile
5355

54-
- name: Update Contracts
56+
- name: Generate Updated Contracts
5557
run: pnpm run generate-contracts
5658

57-
- name: Check for changes
59+
- name: Detect Changes
5860
id: git-check
5961
run: |
60-
git diff --quiet && git diff --staged --quiet || echo "changes_detected=true" >> $GITHUB_OUTPUT
62+
if git diff --quiet && git diff --staged --quiet; then
63+
echo "changes_detected=false" >> $GITHUB_OUTPUT
64+
else
65+
echo "changes_detected=true" >> $GITHUB_OUTPUT
66+
fi
6167
62-
- name: Configure Git
68+
- name: Configure Git Identity
6369
if: steps.git-check.outputs.changes_detected == 'true'
6470
run: |
6571
git config --local user.email "action@github.com"
6672
git config --local user.name "GitHub Action"
6773
68-
- name: Increment package version and commit
74+
- name: Bump Version & Commit
6975
if: steps.git-check.outputs.changes_detected == 'true'
7076
run: |
71-
# Increment version based on selected bump type and get the new version
7277
BUMP_TYPE="${{ github.event.inputs.release_type }}"
7378
PREID="${{ github.event.inputs.preid }}"
7479
echo "Selected version bump: $BUMP_TYPE"
7580
if [ "$BUMP_TYPE" = "prerelease" ] && [ -n "$PREID" ]; then
76-
echo "Using preid: $PREID"
7781
pnpm version "$BUMP_TYPE" --preid "$PREID" --no-git-tag-version
7882
else
7983
pnpm version "$BUMP_TYPE" --no-git-tag-version
8084
fi
8185
NEW_VERSION=$(node -p "require('./package.json').version")
8286
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
83-
84-
# Commit all changes
8587
git add .
8688
git commit -m "chore: update contracts to v$NEW_VERSION"
8789
git push origin main
8890
89-
- name: Build
91+
- name: Build Package
9092
if: steps.git-check.outputs.changes_detected == 'true'
9193
run: pnpm build
9294

93-
- name: Publish to npm
95+
- name: Publish to npm Registry
9496
if: steps.git-check.outputs.changes_detected == 'true'
9597
run: |
96-
echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" > ~/.npmrc
98+
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
9799
pnpm publish --no-git-checks
98100
env:
99101
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100102

101-
- name: Setup Node.js for GitHub Packages
103+
- name: Setup Node.js (GitHub Packages)
102104
if: steps.git-check.outputs.changes_detected == 'true'
103105
uses: actions/setup-node@v4
104106
with:
105-
node-version: "20"
106-
registry-url: "https://npm.pkg.github.com"
107-
scope: "@roninbuilders"
107+
node-version: '20'
108+
registry-url: 'https://npm.pkg.github.com'
109+
scope: '@roninbuilders'
108110

109111
- name: Publish to GitHub Packages
110112
if: steps.git-check.outputs.changes_detected == 'true'
111113
run: pnpm publish --registry https://npm.pkg.github.com --no-git-checks
112114
env:
113115
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114116

115-
- name: Create and push tag
117+
- name: Create & Push Tag
116118
if: steps.git-check.outputs.changes_detected == 'true'
117119
run: |
118-
# Create and push tag only after successful npm publish
119-
echo "Preparing to tag version v$NEW_VERSION"
120-
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
121-
echo "Tag v$NEW_VERSION already exists, skipping tag creation"
122-
else
123-
git tag "v$NEW_VERSION"
124-
git push origin "v$NEW_VERSION"
125-
fi
120+
echo "Preparing to tag version v$NEW_VERSION"
121+
if git rev-parse "v$NEW_VERSION" >/dev/null 2>&1; then
122+
echo "Tag v$NEW_VERSION already exists, skipping"
123+
else
124+
git tag "v$NEW_VERSION"
125+
git push origin "v$NEW_VERSION"
126+
fi
126127
127128
- name: Create GitHub Release
128129
if: steps.git-check.outputs.changes_detected == 'true'
@@ -134,8 +135,8 @@ jobs:
134135
release_name: "Release v${{ env.NEW_VERSION }}"
135136
body: |
136137
Automated release with updated contracts.
137-
138+
138139
## Changes
139140
- Synchronized with latest contract deployments
140141
draft: false
141-
prerelease: ${{ github.event.inputs.release_type == 'prerelease' }}
142+
prerelease: ${{ github.event.inputs.release_type == 'prerelease' }}

0 commit comments

Comments
 (0)