Version 3.6.1 #12
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 NPM packages | |
on: | |
workflow_dispatch: # Manually, for alpha/beta versions | |
inputs: | |
pre_release_version: | |
description: 'Pre-release version modifier' | |
required: true | |
default: 'e.g. "alpha.1" -> "1.2.3-alpha.1"' | |
push: | |
tags: | |
- '*' | |
- '!*\+[0-9]+' # ignore tags with build metadata (e.g. 1.2.3+20231231010203), | |
# as these are automated builds which only update dictionaries' data | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
cache: 'npm' | |
cache-dependency-path: 'node/package-lock.json' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
working-directory: node | |
run: npm ci | |
- name: Lint/typecheck | |
working-directory: node | |
run: npm run lint | |
- name: Test | |
working-directory: node | |
run: npm run test | |
- name: Calculate package versions | |
# running in the root dir | |
run: | | |
pre_release_version_input='${{ inputs.pre_release_version }}' | |
if [[ -z "$pre_release_version_input" ]]; then | |
pre_release_version="" | |
else | |
pre_release_version="+$pre_release_version_input" | |
fi | |
version=$(./gradlew properties | grep 'version: .*' | cut -d' ' -f2 | tr -d '[:space:]') | |
echo "Version from Gradle properties: $version" | |
version="${version}${pre_release_version}" | |
echo "Version with build metadata: $version" | |
echo "PACKAGES_VERSION=$version" >> $GITHUB_ENV | |
- name: Update package versions | |
working-directory: node | |
run: | | |
npm version '${{ env.PACKAGES_VERSION }}' -w packages/jmdict-simplified-types | |
npm version '${{ env.PACKAGES_VERSION }}' -w packages/jmdict-simplified-loader | |
# Use the same version of types in loader | |
npm i '@scriptin/jmdict-simplified-types@${{ env.PACKAGES_VERSION }}' -w packages/jmdict-simplified-loader | |
# Update top-level version in monorepo | |
npm version '${{ env.PACKAGES_VERSION }}' | |
- name: Build | |
working-directory: node | |
run: npm run build | |
- name: Publish | |
working-directory: node | |
run: npm publish --access public --workspaces | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |