Publish #111
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
version_type: | |
type: choice | |
description: Version type | |
default: minor | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: refs/heads/main | |
- name: Setup git repo | |
run: | | |
git config user.name $GITHUB_ACTOR | |
git config user.email gh-actions-${GITHUB_ACTOR}@github.com | |
git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- run: npm install | |
- name: Version | |
run: | | |
npm version ${{ github.event.inputs.version_type }} --force -m "Version %s" | |
- name: Push release commit and tag to GitHub | |
id: push | |
run: | | |
git push gh-origin HEAD:main --tags | |
echo "tag-name=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | |
- name: Publish to npm | |
run: | | |
npm set //registry.npmjs.org/:_authToken ${{ secrets.NODE_AUTH_TOKEN }} | |
npm publish | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
- name: Package release assets | |
run: | | |
zip assets.zip i18n.js i18n.d.ts | |
zip -gr assets.zip dist/ locales/ | |
- name: Create a Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.push.outputs.tag-name }} | |
generate_release_notes: true | |
files: assets.zip |