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 05a1ce2
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 32 deletions.
43 changes: 43 additions & 0 deletions .github/actions/anchor-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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: Anchor Install
uses: metadaoproject/install-anchor@v2
with:
anchor-version: '0.29.0'
solana-cli-version: '1.17.15'
node-version: '20.10.0'
File renamed without changes.
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 }}
14 changes: 4 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ on:
branches: ['main']

jobs:
build:
build-and-test:
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/anchor-install
- uses: ./.github/actions/npm-install
- run: anchor build
- run: anchor run build_sdk
- run: pnpm run test
- run: pnpm run test
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 05a1ce2

Please sign in to comment.