Skip to content
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: automate publishing package to npm #429

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Publish to npm

on:
push:
branches:
- master
paths:
- 'package.json'

jobs:
check:
runs-on: ubuntu-latest

outputs:
version_changed: ${{ steps.check-version.outputs.version_changed }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Check for version change
id: check-version
run: |
NEW_VERSION="$(node -p "require('./package.json').version")"
git show HEAD^:package.json > .old_package.json
OLD_VERSION="$(node -p "require('./.old_package.json').version")"
if [[ "$NEW_VERSION" != "$OLD_VERSION" ]]; then
echo "version_changed=true" >> "$GITHUB_OUTPUT"
else
echo "version_changed=false" >> "$GITHUB_OUTPUT"
fi

publish:
needs: check
if: needs.check.outputs.version_changed == 'true'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Set package name for npm
run: |
cp package.json package.json.bak
sed 's/"name": "solidity"/"name": "vscode-solidity-langserver"/' package.json.bak > package.json

- name: Build and publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Solidity is the language used in Ethereum to create smart contracts, this extens

It is also available as a standalone LSP:
```sh
npm install -g @juanfranblanco/vscode-solidity-server
vscode-solidity-server --stdio
npm install -g vscode-solidity-langserver
vscode-solidity-langserver --stdio
```

# Instructions
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"nethereum",
"solhint"
],
"version": "0.0.165",
"version": "0.0.166",
"publisher": "JuanBlanco",
"license": "MIT",
"engines": {
Expand All @@ -36,7 +36,7 @@
],
"main": "./out/src/extension",
"bin": {
"vscode-solidity-server": "./dist/cli/server.js"
"vscode-solidity-langserver": "./dist/cli/server.js"
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
1 change: 1 addition & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const baseOptions = (options: Options) => ({
clean: true,
bundle: !options.watch,
minify: !options.watch,
sourcemap: true,
})

export default defineConfig(baseOptions);