Skip to content

Commit

Permalink
fix(ci): Upgrade CI/CD pipeline for semver and changelog
Browse files Browse the repository at this point in the history
- Configure a new template for changelog
- Update dependencies
- Use partial cache functionality to speed up builds
  • Loading branch information
taliesins committed Dec 31, 2023
1 parent a0d15c9 commit a1c005a
Show file tree
Hide file tree
Showing 5 changed files with 319 additions and 185 deletions.
59 changes: 39 additions & 20 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
{{ if .Versions -}}
{{ if .Unreleased.CommitGroups }}
{{- $repositoryURL := .Info.RepositoryURL -}}
{{- if .Versions -}}
{{- if .Unreleased.CommitGroups -}}
<a name="unreleased"></a>
## [Unreleased]({{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD)
## [Unreleased]({{ $repositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD)
{{ range .Unreleased.CommitGroups -}}
{{- $commits := list -}}
{{- $title := .Title -}}
{{- range .Commits -}}
{{- if not (and (hasPrefix $title "Chore") (hasPrefix .Scope "release")) -}}
{{- $commits = append $commits . -}}
{{- end -}}
{{- end -}}
{{- if $commits }}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ range $commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}[{{ .Hash.Short }}]({{ $repositoryURL }}/commit/{{ .Hash.Long }}) {{ .Subject }}
{{ end -}}
{{ range .Unreleased.NoteGroups -}}
{{- end -}}
{{- end -}}
{{- range .Unreleased.NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{- range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ range .Versions }}
{{- end -}}
{{- end -}}
{{- range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups -}}
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $repositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups }}
{{- $commits := list -}}
{{- $title := .Title -}}
{{- range .Commits -}}
{{- if not (and (hasPrefix $title "Chore") (hasPrefix .Scope "release")) -}}
{{- $commits = append $commits . -}}
{{- end -}}
{{- end -}}
{{- if $commits }}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ range $commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}[{{ .Hash.Short }}]({{ $repositoryURL }}/commit/{{ .Hash.Long }}) {{ .Subject }}
{{ end -}}
{{ range .NoteGroups -}}
{{- end -}}
{{- end -}}
{{- range .NoteGroups }}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{- end -}}
{{- end -}}
{{- end -}}
18 changes: 12 additions & 6 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
with:
# Fetches entire history, so we can analyze commits since last tag
fetch-depth: 0
persist-credentials: false
persist-credentials: true
fetch-tags: true
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.CREATE_TAG_GITHUB_TOKEN }}
- uses: Bpazy/setup-git-chglog@v1
with:
git-chglog-version: ${{ env.GIT_CHGLOG_VERSION}}
Expand All @@ -31,19 +35,21 @@ jobs:
prerelease_version="$(svu prerelease --tag-mode all-branches --strip-prefix --pre-release prerelease)"
release_version="$(svu next --tag-mode all-branches --strip-prefix)"
echo ::set-output name=CURRENT_VERSION::${current_version}
echo ::set-output name=PRERELEASE_VERSION::${prerelease_version}
echo ::set-output name=RELEASE_VERSION::${release_version}
echo "CURRENT_VERSION=${current_version}" >> $GITHUB_OUTPUT
echo "PRERELEASE_VERSION=${prerelease_version}" >> $GITHUB_OUTPUT
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_OUTPUT
echo "current version: ${current_version}"
echo "prerelease version: ${prerelease_version}"
echo "release version: ${release_version}"
- name: generate change log for release
run: |
git-chglog --next-tag "v${{ steps.get_version.outputs.RELEASE_VERSION }}" > CHANGELOG.md
- name: Add updated changelog
- name: Add updated changelog and create tag
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "chore(release): v${{ steps.get_version.outputs.RELEASE_VERSION }}"
add: "CHANGELOG.md"
tag: "v${{ steps.get_version.outputs.RELEASE_VERSION }}"
tag_push: '--force'
Loading

0 comments on commit a1c005a

Please sign in to comment.