Merge pull request #413 from onflow/auto-update-onflow-cadence-v1.0.0… #42
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |