# publish on npm when there is a new version tag name: publish on: push: tags: [v*] jobs: publish: runs-on: ubuntu-latest strategy: matrix: node-version: [16.x] steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: registry-url: "https://registry.npmjs.org" node-version: ${{ matrix.node-version }} cache: "yarn" - name: install dependencies run: yarn install - name: build run: yarn build - name: run test run: yarn test - name: publish to npm # only run when tag has no 'rc' in it if: ${{ !contains(github.ref, 'rc') }} run: yarn publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: publish beta to npm # only run when tag has 'rc' in it if: ${{ contains(github.ref, 'rc') }} run: yarn publish --access public --tag beta env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: generate changelog uses: orhun/git-cliff-action@v2 id: cliff with: args: --latest --strip footer env: OUTPUT: CHANGES.md - name: save changelog id: changelog shell: bash run: | changelog=$(cat ${{ steps.cliff.outputs.changelog }}) changelog="${changelog//'%'/'%25'}" changelog="${changelog//$'\n'/'%0A'}" changelog="${changelog//$'\r'/'%0D'}" echo "changelog=$changelog" >> $GITHUB_OUTPUT - name: create release id: release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} release_name: Release ${{ github.ref }} body: ${{ steps.changelog.outputs.changelog }} draft: false prerelease: false