1+ name : Release
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ permissions :
9+ contents : write
10+
11+ jobs :
12+ release :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+
20+ - name : Install svu
21+ run : |
22+ curl -sL https://github.com/caarlos0/svu/releases/download/v2.3.0/svu_2.3.0_linux_amd64.tar.gz | tar xvz
23+ sudo mv svu /usr/local/bin/
24+
25+ - name : Get current version
26+ id : current
27+ run : |
28+ CURRENT=$(svu current 2>/dev/null || echo "v0.0.0")
29+ echo "version=$CURRENT" >> $GITHUB_OUTPUT
30+
31+ - name : Calculate next patch version
32+ id : next
33+ run : |
34+ NEXT=$(svu patch)
35+ echo "version=$NEXT" >> $GITHUB_OUTPUT
36+
37+ - name : Check if version changed
38+ id : check
39+ run : |
40+ if [ "${{ steps.current.outputs.version }}" == "${{ steps.next.outputs.version }}" ]; then
41+ echo "changed=false" >> $GITHUB_OUTPUT
42+ echo "No new commits since last release"
43+ else
44+ echo "changed=true" >> $GITHUB_OUTPUT
45+ echo "New version: ${{ steps.next.outputs.version }}"
46+ fi
47+
48+ - name : Create and push tag
49+ if : steps.check.outputs.changed == 'true'
50+ run : |
51+ git config user.name "github-actions[bot]"
52+ git config user.email "github-actions[bot]@users.noreply.github.com"
53+ git tag ${{ steps.next.outputs.version }}
54+ git push origin ${{ steps.next.outputs.version }}
55+
56+ - name : Create GitHub Release
57+ if : steps.check.outputs.changed == 'true'
58+ uses : actions/create-release@v1
59+ env :
60+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61+ with :
62+ tag_name : ${{ steps.next.outputs.version }}
63+ release_name : ${{ steps.next.outputs.version }}
64+ draft : false
65+ prerelease : false
66+ body : |
67+ Automated patch release ${{ steps.next.outputs.version }}
68+
69+ See [CHANGELOG](https://github.com/${{ github.repository }}/compare/${{ steps.current.outputs.version }}...${{ steps.next.outputs.version }}) for details.
0 commit comments