name: Create Release on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Fetch tags run: git fetch --tags - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '23' - name: Install dependencies run: npm install - name: Build project run: npm 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 dist - 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