1+ # GitHub Releasing Workflow
2+ name : GitHub - Release
3+
4+ on :
5+ workflow_distach :
6+ inputs :
7+ bump :
8+ type : choice
9+ description : " The type of version bump to perform"
10+ options :
11+ - patch
12+ - minor
13+ - major
14+
15+ workflow_call :
16+ inputs :
17+ version :
18+ description : " The version to release"
19+ required : true
20+ type : string
21+
22+ permissions :
23+ contents : write
24+
25+ jobs :
26+ release-next :
27+ runs-on : ubuntu-latest
28+ # If the workflow was triggered by workflow_dispatch
29+ if : ${{ github.event_name == 'workflow_dispatch' }}
30+ steps :
31+ - name : " Checkout"
32+ uses : actions/checkout@v3
33+
34+ - name : " Patch Release Me"
35+ uses : 42ByteLabs/patch-release-me@0.3.0
36+ with :
37+ mode : ${{ github.event.inputs.bump }}
38+
39+ - name : " Create Release"
40+ uses : peter-evans/create-pull-request@v6
41+ with :
42+ token : ${{ github.token }}
43+ commit-message : " [chore]: Create release for ${{ github.event.inputs.version }}"
44+ title : " [chore]: Create release for ${{ github.event.inputs.version }}"
45+ branch : chore-release-${{ github.event.inputs.version }}
46+ base : ${{ github.event.before }}
47+ labels : version
48+ body : |
49+ This is an automated PR to create a new release. The release will be created once this PR is merged.
50+
51+ release :
52+ runs-on : ubuntu-latest
53+ # If the workflow was triggered by a workflow call and the version is not null
54+ if : ${{ github.event_name == 'workflow_call' && github.event.inputs.version != null }}
55+ steps :
56+ # https://github.com/peter-murray/semver-data-action
57+ - name : Parse SemVer
58+ id : version
59+ uses : peter-murray/semver-action@v1
60+ with :
61+ version : ${{ inputs.version }}
62+
63+ # Tags :: ${Full}, v${Major}, v${Major}.${Minor}, v${Major}.${Minor}.${Patch}
64+ - name : " GitHub Release"
65+ env :
66+ GH_TOKEN : ${{ github.token }}
67+ run : |
68+ git config user.name github-actions
69+ git config user.email github-actions@github.com
70+
71+ git tag "${{ steps.version.outputs.version }}" --force
72+ git tag "v${{ steps.version.outputs.major }}" --force
73+ git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" --force
74+ git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" --force
75+
76+ git push origin ${{ github.ref_name }}
77+ git push origin --tags --force
78+
79+ gh release create --latest --generate-notes \
80+ --title "v${{ steps.version.outputs.version }}" \
81+ "${{ steps.version.outputs.version }}"
82+
0 commit comments