name: Create Release on: push: branches: - build jobs: build: runs-on: ubuntu-latest steps: - name: check out code uses: actions/checkout@v4 with: ref: ${{ github.ref }} - name: Install Node uses: actions/setup-node@v4 with: node-version: '20.x' registry-url: 'https://registry.npmjs.org' - uses: pnpm/action-setup@v4 with: version: 9 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build project run: pnpm run build - name: Get version from package.json id: get_version run: echo "::set-output name=version::$(node -p "require('./package.json').version")" - name: Set repository variable run: echo "REPO=${{ github.repository }}" >> $GITHUB_ENV - name: Get and format commits run: | last_tag=$(git tag --sort=-v:refname | head -n 1) if [ -z "$last_tag" ]; then git log --pretty=format:"%h - %s" > commits.txt else git log ${last_tag}..HEAD --pretty=format:"%h - %s" > commits.txt fi sed -e "s|^\([a-f0-9]\+\) - \(.*\)|- [\1](https://github.com/$REPO/commit/\1) - \2|" commits.txt > formatted_commits.txt echo "Changes in this release:" > release_body.txt cat formatted_commits.txt >> release_body.txt - name: Create tag run: | git tag v${{ steps.get_version.outputs.version }} git push origin v${{ steps.get_version.outputs.version }} - name: Create Release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: v${{ steps.get_version.outputs.version }} release_name: Release v${{ steps.get_version.outputs.version }} body_path: release_body.txt draft: false prerelease: false - name: Zip dist folder run: zip -r dist.zip src - name: Upload Release Asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: ./dist.zip asset_name: dist.zip asset_content_type: application/zip