Skip to content

Commit

Permalink
feat: optimize actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mindrunner committed Jan 31, 2024
1 parent 51d75df commit 07edf52
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 32 deletions.
40 changes: 40 additions & 0 deletions .github/actions/anchor-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Install Anchor with cached modules'
description: 'Run cargo install anchor-cli with cached modules'

runs:
using: 'composite'
steps:
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-git-
- name: Cache cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-target-
- name: Install Anchor
run: cargo install anchor-cli --version ${{ inputs.anchor-version }}
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
node-version: lts/*

- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-install@v2
id: pnpm-install
with:
run_install: false
Expand Down
19 changes: 19 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Publish'
description: 'Publish the project'

runs:
using: 'composite'
steps:
- name: Install Dependencies
run: cd sdk && pnpm install
shell: bash
- name: Build SDK
run: pnpm run build:sdk
shell: bash
- name: Publish SDK
run: |
pnpm publish --access public \
${{ contains(github.ref_name, 'alpha') && '--tag alpha' || contains(github.ref_name, 'beta') && '--tag beta' || '' }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
25 changes: 16 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Solana Anchor build'
uses: metadaoproject/setup-anchor@v2
with:
anchor-version: '0.29.0'
solana-cli-version: '1.17.15'
node-version: '20.10.0'
- uses: ./.github/actions/install
- uses: ./.github/actions/npm-install
- uses: ./.github/actions/anchor-install
- run: anchor build
- run: anchor run build_sdk
- run: pnpm run test
shell: bash

test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/npm-install
- uses: ./.github/actions/anchor-install
- run: anchor build
shell: bash
- name: Run Tests
run: pnpm run test
shell: bash
24 changes: 2 additions & 22 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
draft: false
Expand All @@ -24,23 +23,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install
- name: 'Solana Anchor build'
uses: metadaoproject/setup-anchor@v2
with:
anchor-version: '0.29.0'
solana-cli-version: '1.17.15'
node-version: '20.10.0'
- uses: ./.github/actions/install
- run: anchor build
- run: anchor run build_sdk
- name: Install Dependencies
run: cd sdk && pnpm install
- name: Build SDK
run: pnpm run build:sdk
- name: Publish SDK
run: |
pnpm publish --access public \
${{ contains(github.ref_name, 'alpha') && '--tag alpha' || contains(github.ref_name, 'beta') && '--tag beta' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: ./.github/actions/publish

0 comments on commit 07edf52

Please sign in to comment.