-
-
Notifications
You must be signed in to change notification settings - Fork 8
96 lines (83 loc) · 2.91 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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 }}