Skip to content

Create Release

Create Release #15

Workflow file for this run

name: Create Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (leave empty for automatic versioning)'
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: |
bun add -g conventional-changelog-cli
bun add -g conventional-recommended-bump
bun add -g conventional-changelog-angular
bun add -g semver
- name: Get version bump
id: bump
if: ${{ !inputs.version }}
run: |
BUMP=$(bunx conventional-recommended-bump -p angular)
echo "bump=$BUMP" >> $GITHUB_OUTPUT
- name: Get current version
id: current_version
run: |
VERSION=$(bun x jq -r .version package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Calculate new version
id: new_version
run: |
if [ -n "${{ inputs.version }}" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo 'import semver from "semver";
const current = "${{ steps.current_version.outputs.version }}";
const bump = "${{ steps.bump.outputs.bump }}";
console.log(semver.inc(current, bump));' > version.mjs
NEW_VERSION=$(bun version.mjs)
rm version.mjs
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
fi
- name: Update version in package.json
run: |
bun x npm version ${{ steps.new_version.outputs.version }} --no-git-tag-version
- name: Generate changelog
run: |
bunx conventional-changelog -p angular -i CHANGELOG.md -s
- name: Create Release Commit
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add CHANGELOG.md package.json
git commit -m "chore(release): v${{ steps.new_version.outputs.version }}"
git tag "v${{ steps.new_version.outputs.version }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.new_version.outputs.version }}
name: Release v${{ steps.new_version.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}