Skip to content

Commit

Permalink
Merge pull request #112 from onflow/ls/automate-release
Browse files Browse the repository at this point in the history
[LS] Publish npm package
  • Loading branch information
sideninja authored May 22, 2023
2 parents 3e08bce + 8b0a48d commit 0cd8fa9
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ls-npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish LS NPM Package

on:
push:
tags:
- 'languageserver/v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
# This only runs this action if the release was made for language server
- uses: actions/checkout@v3
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: "Update package.json"
run: |
tag_name=${GITHUB_REF#refs/tags/}
release_version=$(echo "$tag_name" | awk -F"/v" '{print $2}')
jq '.version = $version' --arg version "$release_version" ./npm-packages/cadence-language-server/package.json > tmp_package.json && mv tmp_package.json ./npm-packages/cadence-language-server/package.json
cat ./npm-packages/cadence-language-server/package.json
release_branch="ls/npm-publish-$(echo $release_version)"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# Commit changes
git add ./npm-packages/cadence-language-server/package.json
git commit -m "Update version to $release_version"
# Create a branch for the changes
git branch $(echo $release_branch)
git checkout $(echo $release_branch)
git push origin $(echo $release_branch)
# Create a pull request with the changes
gh pr create --title "[LS] Update and publish NPM package $release_version" --body "Updating the version in package.json to $release_version and publishing to NPM" --base master --head $(echo $release_branch)
env:
GH_TOKEN: ${{ github.token }}
- name: "Build NPM package"
run: |
cd npm-packages/cadence-language-server
npm install
npm run build
- name: "Publish NPM package"
run: |
cd npm-packages/cadence-language-server
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 0cd8fa9

Please sign in to comment.