-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (70 loc) · 2.33 KB
/
release.yml
File metadata and controls
80 lines (70 loc) · 2.33 KB
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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'CalVer version (e.g. 2026.0.0)'
required: true
type: string
push:
tags:
- '[0-9][0-9][0-9][0-9].*'
permissions:
contents: read
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- name: Validate CalVer format
run: |
if ! echo "${{ steps.version.outputs.tag }}" | grep -qE '^[0-9]{4}\.[0-9]+\.[0-9]+$'; then
echo "Error: Version must be in CalVer format YYYY.MINOR.PATCH (e.g. 2026.0.0)"
exit 1
fi
- name: Create and push tag
if: github.event_name == 'workflow_dispatch'
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Get previous tag
id: previous
run: |
PREVIOUS=$(git tag --sort=-v:refname | grep -E '^[0-9]{4}\.' | grep -v "^${{ steps.version.outputs.tag }}$" | head -1)
echo "tag=$PREVIOUS" >> "$GITHUB_OUTPUT"
- name: Generate changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ steps.version.outputs.tag }}
toTag: ${{ steps.previous.outputs.tag }}
excludeTypes: build,docs,other,style,ci,chore
useGitmojis: false
writeToFile: true
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: ${{ steps.changelog.outputs.changes }}
- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: main
commit_message: "docs: update CHANGELOG for ${{ steps.version.outputs.tag }}"
file_pattern: CHANGELOG.md