Publish to npm #71
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 to npm" | |
on: | |
workflow_dispatch: | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- id: pull-latest-from-main | |
name: 'Get latest code from main branch' | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- id: setup-git-user | |
name: Setup git user | |
run: | | |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" | |
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
registry-url: 'https://registry.npmjs.org' | |
- id: generate-a-version-patch | |
name: 'Generate version patch for later' | |
run: npm version patch | |
- id: pull-latest-schema-files | |
name: 'Get latest schema files' | |
uses: actions/checkout@v4 | |
with: | |
repository: 'cmxiv/google-workspace-addon-json-schema' | |
ref: main | |
path: schema | |
- id: copy-remaining-schema-files | |
name: 'Copy remaining schema files' | |
run: cp -r schema/* . | |
- id: generate-types | |
name: 'Generate the typescript types' | |
run: | | |
npm i g quicktype | |
npm run build | |
- id: copy-generated-file | |
name: 'Copy the generated files to the workspace' | |
run: cp generated/typescript/* . | |
- id: publish | |
name: 'Publish to NPM' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | |
- id: clean-up-after-publish | |
name: 'Clean up after publish' | |
run: | | |
rm *.schema.json *.ts *.sh | |
rm -rf examples generated schema | |
- id: push-version-changes | |
name: 'Push the bumped up version' | |
run: git push --follow-tags |