Skip to content

cleaner workflow syntax #8

cleaner workflow syntax

cleaner workflow syntax #8

name: GBFS Validator Package - Publish
on:
push:
branches:
- master
- fix/publish-workflow
jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./gbfs-validator
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get current published version
id: get_current_published_version
run: echo "VERSION=$(npm info gbfs-validator version)" >> $GITHUB_OUTPUT
- name: Get current local version
id: get_current_local_version
run: echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
- name: Check if version changed
env:
CURRENT_VERSION: ${{ steps.get_current_published_version.outputs.VERSION }}
LOCAL_VERSION: ${{ steps.get_current_local_version.outputs.VERSION }}
run: |
if [ "$CURRENT_VERSION" != "$LOCAL_VERSION" ]; then
echo "Version changed from $CURRENT_VERSION to $LOCAL_VERSION"
else
echo "Version did not change"
exit 0
fi
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}