compile to esm and cjs #194
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: build | |
on: | |
pull_request: | |
push: | |
branches: [ master ] | |
tags: | |
- .* | |
jobs: | |
build_test_and_publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 19.4.0 | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Compile the typescript | |
run: npm run compile | |
- name: Lint the code | |
run: npm run lint | |
- name: Run the tests | |
run: npm test | |
- name: Copy relevant documentation into the build folder | |
run: cp package.json README.md LICENSE-APACHE LICENSE-MIT ./build | |
- name: Publish to npmjs | |
uses: JS-DevTools/npm-publish@v1 | |
if: github.ref == 'refs/heads/master' | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: build/package.json | |
# don't try and deploy if versions haven't changed | |
check-version: true | |
- name: Check for version change | |
id: version-check | |
run: | | |
[ "$(git show head^:package.json | jq .version)" = "$(cat package.json | jq .version)" ] && echo "::set-output name=version_changed::true" || echo "::set-output name=version_changed::false" | |
- name: Create tag variable | |
id: tagging | |
if: github.ref == 'refs/heads/master' && steps.version-check.outputs.version_changed == 'true' | |
run: echo "::set-output name=new_tag::v$(cat package.json | jq .version | sed "s/['\"]//g")" | |
- name: Create a GitHub release | |
if: github.ref == 'refs/heads/master' && steps.version-check.outputs.version_changed == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
custom_tag: ${{ steps.tagging.outputs.new_tag }} | |
name: Release ${{ steps.tagging.outputs.new_tag }} | |
body: ${{ steps.tag_version.outputs.changelog }} |