-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: publish npm workflow #21
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Publish to NPM | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "21" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install Rust | ||
run: | | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
source $HOME/.cargo/env | ||
|
||
- name: Install Solana CLI | ||
run: | | ||
sh -c "$(curl -sSfL https://release.solana.com/v1.18.15/install)" | ||
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH" | ||
solana --version | ||
|
||
- name: Install Anchor CLI | ||
run: | | ||
cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.0 anchor-cli --locked | ||
anchor --version | ||
fbac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Build | ||
run: anchor build | ||
|
||
- name: Prepare IDL Files | ||
run: | | ||
mv target/idl ./ | ||
fbac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Determine NPM Tag | ||
id: determine-npm-tag | ||
run: | | ||
VERSION_TAG=${GITHUB_REF#refs/tags/v} | ||
if [[ $VERSION_TAG == *"-"* ]]; then | ||
echo ::set-output name=NPM_TAG::${VERSION_TAG#*-} | ||
else | ||
echo ::set-output name=NPM_TAG::latest | ||
fi | ||
env: | ||
GITHUB_REF: ${{ github.ref }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is deprecated by GitHub, please consider using:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry, but this has never worked for me. I propose we improve this in a follow-up PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a working example in a workflow on this repository:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
- name: Publish to NPM | ||
run: | | ||
yarn publish --access public --new-version ${GITHUB_REF#refs/tags/v} --tag ${{ | ||
steps.determine-npm-tag.outputs.NPM_TAG }} --no-git-tag-version | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GITHUB_REF: ${{ github.ref }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
71e859a