v5.3.0 - Import features #10
Workflow file for this run
This file contains hidden or 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: Deploy release to NPM | |
on: | |
release: | |
types: [published] | |
jobs: | |
publish-to-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
# Enables caching Yarn dependencies (uses https://github.com/actions/cache under the hood) | |
cache: 'yarn' | |
registry-url: 'https://registry.npmjs.org' | |
always-auth: true | |
- name: Create env variables | |
run: | | |
RELEASE_VERSION=${{ github.event.release.tag_name }} | |
NEW_VERSION_NUMBER=${RELEASE_VERSION/v} | |
echo NEW_VERSION_NUMBER=$NEW_VERSION_NUMBER >> $GITHUB_ENV | |
echo Publishing $NEW_VERSION_NUMBER | |
- name: setup git config | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
# Sets the version number in package.json | |
# Invoked with --no-git-tag-version because the tag is already created by Github Release | |
- name: Bump package version | |
run: yarn version --new-version $NEW_VERSION_NUMBER --no-git-tag-version | |
- name: Commit package version bump | |
run: | | |
git add package.json | |
git commit -m "chore: Release ${{ github.event.release.tag_name }}" | |
# Builds and publishes the package. | |
# Invoked with --no-git-tag-version because the tag is already created by Github Release | |
- name: Build and publish the package | |
run: yarn publish --non-interactive --no-git-tag-version | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Replace tag and push commit | |
run: | | |
git push origin --delete ${{ github.event.release.tag_name }} | |
git tag -af ${{ github.event.release.tag_name }} -m "Release ${{ github.event.release.tag_name }}" | |
git push origin master --follow-tags |