Skip to content

Commit

Permalink
chore: Refactor GitHub Actions workflows for linting, testing, and bu…
Browse files Browse the repository at this point in the history
…ilding
  • Loading branch information
abdelkrimdev committed Jun 10, 2024
1 parent 52f0c19 commit 8432736
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 31 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/build-and-lint.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Lint, Test, and Build

on:
release:
types: [created]
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm lint
- name: Build
run: pnpm build
34 changes: 24 additions & 10 deletions .github/workflows/npm-publish.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package
name: Publish MeshSDK Packages

on:
pull_request:
Expand All @@ -13,12 +13,26 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
node-version: 20
- run: yarn ci
version: 9
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm lint
- name: Build
run: pnpm build

check-version:
runs-on: ubuntu-latest
Expand All @@ -36,7 +50,7 @@ jobs:
- name: Get package version from main branch before merge
id: pre-merge-version
run: |
CORE_PRE_MERGE_VERSION=$(node -p "require('./packages/module/package.json').version")
CORE_PRE_MERGE_VERSION=$(node -p "require('./packages/core/package.json').version")
REACT_PRE_MERGE_VERSION=$(node -p "require('./packages/react/package.json').version")
CONTRACTS_PRE_MERGE_VERSION=$(node -p "require('./packages/contracts/package.json').version")
echo "core_pre_merge_version=$CORE_PRE_MERGE_VERSION" >> "$GITHUB_OUTPUT"
Expand All @@ -51,7 +65,7 @@ jobs:
- name: Get package version from main branch after merge
id: post-merge-version
run: |
CORE_POST_MERGE_VERSION=$(node -p "require('./packages/module/package.json').version")
CORE_POST_MERGE_VERSION=$(node -p "require('./packages/core/package.json').version")
REACT_POST_MERGE_VERSION=$(node -p "require('./packages/react/package.json').version")
CONTRACTS_POST_MERGE_VERSION=$(node -p "require('./packages/contracts/package.json').version")
echo "core_post_merge_version=$CORE_POST_MERGE_VERSION" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -87,8 +101,8 @@ jobs:
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: yarn ci
- run: cd packages/module && npm publish --access public
- run: pnpm build
- run: cd packages/core && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

Expand All @@ -102,7 +116,7 @@ jobs:
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: yarn ci
- run: pnpm build
- run: cd packages/react && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Expand All @@ -117,7 +131,7 @@ jobs:
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: yarn ci
- run: pnpm build
- run: cd packages/contracts && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

0 comments on commit 8432736

Please sign in to comment.