From a1c005af6500bb42040043d044a34fb92152d9ca Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Sun, 31 Dec 2023 00:51:04 +0000 Subject: [PATCH] fix(ci): Upgrade CI/CD pipeline for semver and changelog - Configure a new template for changelog - Update dependencies - Use partial cache functionality to speed up builds --- .chglog/CHANGELOG.tpl.md | 59 +++-- .github/workflows/create-release.yml | 18 +- .github/workflows/release.yml | 334 ++++++++++++++++++--------- .gitignore | 1 + CHANGELOG.md | 92 ++++---- 5 files changed, 319 insertions(+), 185 deletions(-) diff --git a/.chglog/CHANGELOG.tpl.md b/.chglog/CHANGELOG.tpl.md index 1392af52..75526c0e 100644 --- a/.chglog/CHANGELOG.tpl.md +++ b/.chglog/CHANGELOG.tpl.md @@ -1,34 +1,53 @@ -{{ if .Versions -}} -{{ if .Unreleased.CommitGroups }} +{{- $repositoryURL := .Info.RepositoryURL -}} +{{- if .Versions -}} +{{- if .Unreleased.CommitGroups -}} -## [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 }} -## {{ 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 -}} \ No newline at end of file +{{- end -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 340540a7..42fd8b27 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -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}} @@ -31,9 +35,9 @@ 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}" @@ -41,9 +45,11 @@ jobs: - 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' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03922dcf..d14a272b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,16 +50,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Cache cache-go-pkg-mod - uses: actions/cache@v3.3.1 + - uses: actions/cache@v3.3.2 continue-on-error: true id: cache-go-pkg-mod - timeout-minutes: 2 + timeout-minutes: 3 with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' @@ -72,33 +76,49 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-pkg-mod + timeout-minutes: 3 + with: + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-build + timeout-minutes: 3 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-build - name: Cache cache-terraform-plugin-dir - uses: actions/cache@v3.3.1 + uses: actions/cache@v3.3.2 continue-on-error: true id: cache-terraform-plugin-dir timeout-minutes: 2 with: - path: terraform-plugin-dir - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' - uses: actions/setup-go@v4 + path: | + terraform-plugin-dir + key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' || steps.cache-go-build.outputs.cache-hit != 'true' || steps.cache-go-build.outcome == 'failure' || steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' + uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} - - if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' - name: go env - run: | - echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV - - if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' - uses: actions/cache@v3.3.1 - with: - path: ${{ env.GOCACHE }} - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' - uses: actions/cache@v3.3.1 - with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} - - if: steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' + name: go mod download + run: go mod download + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' || steps.cache-go-build.outputs.cache-hit != 'true' || steps.cache-go-build.outcome == 'failure' || steps.cache-terraform-plugin-dir.outputs.cache-hit != 'true' || steps.cache-terraform-plugin-dir.outcome == 'failure' name: go build run: go build -o terraform-plugin-dir/registry.terraform.io/hashicorp/hyperv/99.99.99/linux_amd64/terraform-provider-hyperv_v99.99.99 @@ -109,19 +129,28 @@ jobs: steps: - uses: actions/checkout@v4 - name: Cache cache-terraform-providers-schema - uses: actions/cache@v3.3.1 + uses: actions/cache@v3.3.2 continue-on-error: true id: cache-terraform-providers-schema timeout-minutes: 2 with: - path: terraform-providers-schema - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-terraform-providers-schema-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' - uses: actions/cache@v3.3.1 + path: | + terraform-providers-schema + key: ${{ runner.os }}-terraform-providers-schema-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + - name: Cache cache-terraform-plugin-dir + uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-terraform-plugin-dir timeout-minutes: 2 with: - path: terraform-plugin-dir - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + path: | + terraform-plugin-dir + key: ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-terraform-plugin-dir-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-terraform-plugin-dir- + - if: steps.cache-terraform-providers-schema.outputs.cache-hit != 'true' || steps.cache-terraform-providers-schema.outcome == 'failure' uses: hashicorp/setup-terraform@v3.0.0 with: @@ -145,24 +174,38 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - name: go env - run: | - echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV - - uses: actions/cache@v3.3.1 + - uses: actions/cache@v3.3.2 continue-on-error: true - timeout-minutes: 2 + id: cache-go-pkg-mod + timeout-minutes: 3 with: - path: ${{ env.GOCACHE }} - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - uses: actions/cache@v3.3.1 + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod + - uses: actions/cache@v3.3.2 continue-on-error: true - timeout-minutes: 2 + id: cache-go-build + timeout-minutes: 3 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-build + - uses: actions/setup-go@v5 with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} + go-version: ${{ env.GO_VERSION }} + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' + name: go mod download + run: go mod download + - run: go generate ./... - name: Check for Git Differences run: | @@ -174,53 +217,81 @@ jobs: needs: [go_build] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - name: go env - run: | - echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV - - uses: actions/cache@v3.3.1 - continue-on-error: true - timeout-minutes: 2 - with: - path: ${{ env.GOCACHE }} - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - uses: actions/cache@v3.3.1 - continue-on-error: true - timeout-minutes: 2 - with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} - - run: go test ./... -timeout=${{ env.TEST_TIME_OUT }} + - uses: actions/checkout@v4 + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-pkg-mod + timeout-minutes: 3 + with: + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-build + timeout-minutes: 3 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-build + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' + name: go mod download + run: go mod download + + - run: go test ./... -timeout=${{ env.TEST_TIME_OUT }} golangci-lint: needs: [go_build] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - name: go env - run: | - echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_ENV - - uses: actions/cache@v3.3.1 - continue-on-error: true - timeout-minutes: 2 - with: - path: ${{ env.GOCACHE }} - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} - - uses: actions/cache@v3.3.1 - continue-on-error: true - timeout-minutes: 2 - with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} - - run: go get -d github.com/golangci/golangci-lint/cmd/golangci-lint - - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint - - run: golangci-lint run + - uses: actions/checkout@v4 + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-pkg-mod + timeout-minutes: 3 + with: + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-build + timeout-minutes: 3 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-build + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' + name: go mod download + run: go mod download + + - run: go get -d github.com/golangci/golangci-lint/cmd/golangci-lint + - run: go install github.com/golangci/golangci-lint/cmd/golangci-lint + - run: golangci-lint run semgrep: # User definable name of this GitHub Actions job. @@ -249,12 +320,49 @@ jobs: SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} goreleaser: - needs: [go_mod_download] + needs: [go_build] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + 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: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-pkg-mod + timeout-minutes: 3 + with: + path: | + ~/go/pkg/mod + key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-pkg-mod-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-pkg-mod + - uses: actions/cache@v3.3.2 + continue-on-error: true + id: cache-go-build + timeout-minutes: 3 + with: + path: | + ~/.cache/go-build + key: ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + restore-keys: | + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('internal/**', 'api/**', 'powershell/**') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }}-${{ hashFiles('**/go.sum') }} + ${{ runner.os }}-go-build-${{ hashFiles('.github/workflows/release.yml') }} + ${{ runner.os }}-go-build + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - if: steps.cache-go-pkg-mod.outputs.cache-hit != 'true' || steps.cache-go-pkg-mod.outcome == 'failure' + name: go mod download + run: go mod download + - uses: Bpazy/setup-git-chglog@v1 with: git-chglog-version: ${{ env.GIT_CHGLOG_VERSION}} @@ -267,25 +375,19 @@ jobs: id: get_version run: | current_version="$(svu current --tag-mode current-branch --strip-prefix)" + previous_version="$(git tag -l --sort=-version:refname | grep -E '^v.*' | head -n2 | sed -n 2p | cut -c 2-)" 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 "PREVIOUS_VERSION=${previous_version}" >> $GITHUB_OUTPUT + echo "PRERELEASE_VERSION=${prerelease_version}" >> $GITHUB_OUTPUT + echo "RELEASE_VERSION=${release_version}" >> $GITHUB_OUTPUT echo "current version: ${current_version}" + echo "previous version: ${previous_version}" echo "prerelease version: ${prerelease_version}" echo "release version: ${release_version}" - - uses: actions/setup-go@v4 - with: - go-version: ${{ env.GO_VERSION }} - - uses: actions/cache@v3.3.1 - continue-on-error: true - timeout-minutes: 2 - with: - path: ~/go/pkg/mod - key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }} - name: goreleaser check continue-on-error: true uses: goreleaser/goreleaser-action@v5 @@ -293,22 +395,24 @@ jobs: args: check - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@v6.0.0 + uses: crazy-max/ghaction-import-gpg@v6.1.0 if: startsWith(github.ref, 'refs/tags/v') with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} #passphrase: ${{ secrets.PASSPHRASE }} + - name: goreleaser release uses: goreleaser/goreleaser-action@v5 if: startsWith(github.ref, 'refs/tags/v') with: version: latest - args: release --rm-dist --timeout ${{ env.RELEASE_TIME_OUT }} --release-notes=CHANGELOG.md + args: release --clean --timeout ${{ env.RELEASE_TIME_OUT }} --release-notes=CHANGELOG.md env: GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_CURRENT_TAG: ${{ steps.get_version.outputs.RELEASE_VERSION }} - GORELEASER_PREVIOUS_TAG: ${{ steps.get_version.outputs.CURRENT_VERSION }} + GORELEASER_CURRENT_TAG: "v${{ steps.get_version.outputs.RELEASE_VERSION }}" + GORELEASER_PREVIOUS_TAG: "v${{ steps.get_version.outputs.PREVIOUS_VERSION }}" + - name: generate change log for prerelease if: "!(startsWith(github.ref, 'refs/tags/v'))" run: | @@ -317,10 +421,10 @@ jobs: uses: goreleaser/goreleaser-action@v5 if: "!(startsWith(github.ref, 'refs/tags/v'))" with: - args: release --rm-dist --skip-sign --snapshot --timeout ${{ env.RELEASE_TIME_OUT }} --release-notes=CHANGELOG.md + args: release --clean --skip=sign --snapshot --timeout ${{ env.RELEASE_TIME_OUT }} --release-notes=CHANGELOG.md env: - GORELEASER_CURRENT_TAG: ${{ steps.get_version.outputs.RELEASE_VERSION }} - GORELEASER_PREVIOUS_TAG: ${{ steps.get_version.outputs.CURRENT_VERSION }} + GORELEASER_CURRENT_TAG: "v${{ steps.get_version.outputs.RELEASE_VERSION }}" + GORELEASER_PREVIOUS_TAG: "v${{ steps.get_version.outputs.CURRENT_VERSION }}" - name: snapshot artifact naming id: naming if: "!(startsWith(github.ref, 'refs/tags/v'))" @@ -334,18 +438,20 @@ jobs: *) ARTIFACT="${GITHUB_REF}";; esac - echo "::set-output name=ARTIFACT::$ARTIFACT-$(date -u +'%Y-%m-%dT%H-%M')" + + ARTIFACT="${ARTIFACT}-$(date -u +'%Y-%m-%dT%H-%M')" + echo "ARTIFACT=${ARTIFACT}" >> $GITHUB_OUTPUT - name: upload snapshot artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: "!(startsWith(github.ref, 'refs/tags/v'))" with: name: ${{steps.naming.outputs.ARTIFACT}} path: dist/*.zip - - name: Add updated changelog, and create new branch + + - name: Add updated changelog uses: EndBug/add-and-commit@v9 - if: "!(startsWith(github.ref, 'refs/tags/v'))" + if: "startsWith(github.ref, 'refs/heads/master')" with: default_author: github_actions message: "chore(release): v${{ steps.get_version.outputs.PRERELEASE_VERSION }}" add: "CHANGELOG.md" - new_branch: "v${{ steps.get_version.outputs.PRERELEASE_VERSION }}" diff --git a/.gitignore b/.gitignore index 08503a7e..3e0c62ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +__tools/ *.dll *.exe .DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d0fd6f..f32837cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,74 +1,76 @@ -## [v1.1.0-prerelease.0](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.4...v1.1.0-prerelease.0) (2023-12-26) +## [v1.1.0-prerelease.0](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.4...v1.1.0-prerelease.0) (2023-12-31) + ### Build -- add semantic release +- [7ab008e](https://github.com/taliesins/terraform-provider-hyperv/commit/7ab008e24cac705707c648e11002378d34ad3f29) add semantic release ### Chore -- **deps:** bump golang.org/x/net from 0.7.0 to 0.17.0 -- **deps:** bump amannn/action-semantic-pull-request -- **deps:** bump actions/setup-go from 3 to 4 -- **deps:** bump actions/cache from 3.2.1 to 3.3.1 -- **deps:** bump golang.org/x/net from 0.4.0 to 0.7.0 -- **deps:** bump goreleaser/goreleaser-action from 4.1.0 to 4.2.0 -- **deps:** bump actions/cache from 3.0.11 to 3.2.1 +- **deps:** [46860cc](https://github.com/taliesins/terraform-provider-hyperv/commit/46860cc721e49e4b83634e91c3c90978bbd470da) bump actions/checkout from 3 to 4 +- **deps:** [777fdf6](https://github.com/taliesins/terraform-provider-hyperv/commit/777fdf60ec9c84d382aa02e4c345cfd1f2d8cc6a) bump golang.org/x/crypto from 0.14.0 to 0.17.0 +- **deps:** [65ba5b7](https://github.com/taliesins/terraform-provider-hyperv/commit/65ba5b79f21a1cb10c6b313a0c3d23d05a4d86e7) bump amannn/action-semantic-pull-request +- **deps:** [e5a1ab9](https://github.com/taliesins/terraform-provider-hyperv/commit/e5a1ab9256f1782a9fa9f1e03bfcd43ed7d00aec) bump hashicorp/setup-terraform from 2.0.3 to 3.0.0 +- **deps:** [e0d2b06](https://github.com/taliesins/terraform-provider-hyperv/commit/e0d2b065ebf59d7f314ec4ba6dcb72422b974a14) bump crazy-max/ghaction-import-gpg from 5.2.0 to 6.0.0 +- **deps:** [7ef6010](https://github.com/taliesins/terraform-provider-hyperv/commit/7ef6010f7cdcfdd9bb93c464fcfacf34716f2e19) bump google.golang.org/grpc from 1.51.0 to 1.56.3 +- **deps:** [e8045f2](https://github.com/taliesins/terraform-provider-hyperv/commit/e8045f2914f902dfddd8cbb0abc7d3f052d9dc1d) bump golang.org/x/net from 0.7.0 to 0.17.0 +- **deps:** [22694a3](https://github.com/taliesins/terraform-provider-hyperv/commit/22694a3e439f80f72b2aa29a524aa74d3fd8c23c) bump amannn/action-semantic-pull-request +- **deps:** [395f0a4](https://github.com/taliesins/terraform-provider-hyperv/commit/395f0a432aca0cdf75d898b8058cb390c6e340b7) bump actions/setup-go from 3 to 4 +- **deps:** [72e5111](https://github.com/taliesins/terraform-provider-hyperv/commit/72e51115e6f837449cd6422b41433b616dec8935) bump actions/cache from 3.2.1 to 3.3.1 +- **deps:** [b353437](https://github.com/taliesins/terraform-provider-hyperv/commit/b3534370fbb78cac28627b01fe0f4a8b0a20f016) bump golang.org/x/net from 0.4.0 to 0.7.0 +- **deps:** [59e00c2](https://github.com/taliesins/terraform-provider-hyperv/commit/59e00c28bb8bea65ec6b9ba82687308984272992) bump goreleaser/goreleaser-action from 4.1.0 to 4.2.0 +- **deps:** [68d0fc2](https://github.com/taliesins/terraform-provider-hyperv/commit/68d0fc25ffb168f661110731fb58ee204189197d) bump actions/cache from 3.0.11 to 3.2.1 ### Feat -- fix build +- [5c1fd8b](https://github.com/taliesins/terraform-provider-hyperv/commit/5c1fd8bc40b7124718322fc1f6cbc8ee686a1462) fix build +### Fix +- **ci:** [9553b73](https://github.com/taliesins/terraform-provider-hyperv/commit/9553b7344b9e5ef0c49ab2ba0610526ab54436c9) Upgrade CI/CD pipeline for semver and changelog - Configure a new template for changelog - Update dependencies - Use partial cache functionality to speed up builds ## [v1.0.4](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.3...v1.0.4) (2022-12-14) -### Chore -- **deps:** bump actions/cache from 3.0.8 to 3.0.10 -- **deps:** bump github.com/hashicorp/terraform-plugin-sdk/v2 -- **deps:** bump github.com/hashicorp/terraform-plugin-sdk/v2 -- **deps:** bump hashicorp/setup-terraform from 2.0.2 to 2.0.3 -- **deps:** bump crazy-max/ghaction-import-gpg from 5.1.0 to 5.2.0 -- **deps:** bump goreleaser/goreleaser-action from 3.1.0 to 3.2.0 -- **deps:** bump amannn/action-semantic-pull-request -- **deps:** bump actions/cache from 3.0.10 to 3.0.11 -- **deps:** bump actions/cache from 3.0.2 to 3.0.8 -- **deps:** bump amannn/action-semantic-pull-request -- **deps:** bump actions/upload-artifact from 2 to 3 -- **deps:** bump goreleaser/goreleaser-action from 3.2.0 to 4.1.0 -- **deps:** bump hashicorp/setup-terraform from 2.0.0 to 2.0.2 -- **deps:** bump goreleaser/goreleaser-action from 3.0.0 to 3.1.0 -- **deps:** bump github.com/hashicorp/terraform-plugin-docs -- **deps:** bump crazy-max/ghaction-import-gpg from 4.3.0 to 5.1.0 -- **deps:** bump goreleaser/goreleaser-action from 2.9.1 to 3.0.0 -- **deps:** bump amannn/action-semantic-pull-request -- **deps:** bump amannn/action-semantic-pull-request -- **deps:** bump github.com/jolestar/go-commons-pool/v2 -- **deps:** bump hashicorp/setup-terraform from 1.4.0 to 2.0.0 -- **release:** v1.0.4 +### Chore +- **deps:** [51d8f4b](https://github.com/taliesins/terraform-provider-hyperv/commit/51d8f4b2b809c38ec3adab7c34291c959ad70483) bump actions/cache from 3.0.8 to 3.0.10 +- **deps:** [63e2616](https://github.com/taliesins/terraform-provider-hyperv/commit/63e2616c0d29d925ec3a255c0d1eea7bc5791798) bump github.com/hashicorp/terraform-plugin-sdk/v2 +- **deps:** [3372e5a](https://github.com/taliesins/terraform-provider-hyperv/commit/3372e5af4c5283162bca53a567a36afd50c3ae7f) bump github.com/hashicorp/terraform-plugin-sdk/v2 +- **deps:** [1e445f0](https://github.com/taliesins/terraform-provider-hyperv/commit/1e445f0228f44000d4c224e720ccf477707c9023) bump hashicorp/setup-terraform from 2.0.2 to 2.0.3 +- **deps:** [9dc9339](https://github.com/taliesins/terraform-provider-hyperv/commit/9dc9339b4b9263cb59abab9f124430df0a1250d1) bump crazy-max/ghaction-import-gpg from 5.1.0 to 5.2.0 +- **deps:** [4d6ac61](https://github.com/taliesins/terraform-provider-hyperv/commit/4d6ac612ab4e5d1aa3038a3cf4af8f4256861cd4) bump goreleaser/goreleaser-action from 3.1.0 to 3.2.0 +- **deps:** [85421c4](https://github.com/taliesins/terraform-provider-hyperv/commit/85421c43e84096755b9c06ff03f8bc9a550edfbd) bump amannn/action-semantic-pull-request +- **deps:** [e860385](https://github.com/taliesins/terraform-provider-hyperv/commit/e860385d266c3f18001e7e938f4ead363b69eec9) bump actions/cache from 3.0.10 to 3.0.11 +- **deps:** [a6982c3](https://github.com/taliesins/terraform-provider-hyperv/commit/a6982c31c0c8c17d42c036208492a5011edb97bd) bump actions/cache from 3.0.2 to 3.0.8 +- **deps:** [9f29a71](https://github.com/taliesins/terraform-provider-hyperv/commit/9f29a7153a06d2f101a129aa8124b508c826954d) bump amannn/action-semantic-pull-request +- **deps:** [6e0f104](https://github.com/taliesins/terraform-provider-hyperv/commit/6e0f104451bcb02498667c8622398718461af078) bump actions/upload-artifact from 2 to 3 +- **deps:** [dc03fb8](https://github.com/taliesins/terraform-provider-hyperv/commit/dc03fb8bd16ad2284cc5db77c5a7461eb17955da) bump goreleaser/goreleaser-action from 3.2.0 to 4.1.0 +- **deps:** [5075896](https://github.com/taliesins/terraform-provider-hyperv/commit/507589668fc6a2359104dcc49a33dfd62b1cdcb7) bump hashicorp/setup-terraform from 2.0.0 to 2.0.2 +- **deps:** [0422b3f](https://github.com/taliesins/terraform-provider-hyperv/commit/0422b3fac65e271667b9ed81de639268ecf5a66b) bump goreleaser/goreleaser-action from 3.0.0 to 3.1.0 +- **deps:** [30f7554](https://github.com/taliesins/terraform-provider-hyperv/commit/30f7554aacb7d02cf4e2e31e9f42ded5ecb2fd9f) bump github.com/hashicorp/terraform-plugin-docs +- **deps:** [50e34f2](https://github.com/taliesins/terraform-provider-hyperv/commit/50e34f25ddb55a480a099d840a58140d405d7340) bump crazy-max/ghaction-import-gpg from 4.3.0 to 5.1.0 +- **deps:** [e9cbaf8](https://github.com/taliesins/terraform-provider-hyperv/commit/e9cbaf84b63ffb039885c5576bb14ba88319aec5) bump goreleaser/goreleaser-action from 2.9.1 to 3.0.0 +- **deps:** [a4e2008](https://github.com/taliesins/terraform-provider-hyperv/commit/a4e2008de1e53018992d1ea9bd19f52e30ace7e7) bump amannn/action-semantic-pull-request +- **deps:** [6e086ac](https://github.com/taliesins/terraform-provider-hyperv/commit/6e086ac03b73f16ac9ed879b282c7c5b43780203) bump amannn/action-semantic-pull-request +- **deps:** [90eb2b1](https://github.com/taliesins/terraform-provider-hyperv/commit/90eb2b1834fc01e0595ca22f8b9442907b92dee2) bump github.com/jolestar/go-commons-pool/v2 +- **deps:** [176ca62](https://github.com/taliesins/terraform-provider-hyperv/commit/176ca62bba8b2d62438621887c0b8e2963fe5e0e) bump hashicorp/setup-terraform from 1.4.0 to 2.0.0 ## [v1.0.3](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.2...v1.0.3) (2021-03-20) -### Chore -- **release:** v1.0.3 ### Fix -- improve error message to make it obvious what to do when this error occurs -- **static-or-dynamic:** use schema to ensure exclusive selection of dynamic or static memory -- **static-or-dynamic:** don't default to static, but rather force people to chose static over dynamic. - +- [da23bf6](https://github.com/taliesins/terraform-provider-hyperv/commit/da23bf6c7acde50fbe3bc14b2a7d5a4f0b96f3e1) improve error message to make it obvious what to do when this error occurs +- **static-or-dynamic:** [89a245e](https://github.com/taliesins/terraform-provider-hyperv/commit/89a245e71e427f846fe8144b55afc277896c31a5) use schema to ensure exclusive selection of dynamic or static memory +- **static-or-dynamic:** [da10a53](https://github.com/taliesins/terraform-provider-hyperv/commit/da10a536792f8f3cecba6c988c011eff65866812) don't default to static, but rather force people to chose static over dynamic. ## [v1.0.2](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.1...v1.0.2) (2021-03-09) -### Chore -- **release:** v1.0.2 ### Ci -- do not persist credentials - +- [db19a46](https://github.com/taliesins/terraform-provider-hyperv/commit/db19a46de238f8bdf5ce83a6694ebaf6a8e91585) do not persist credentials ## [v1.0.1](https://github.com/taliesins/terraform-provider-hyperv/compare/v1.0.0...v1.0.1) (2020-09-23) ## v1.0.0 (2020-09-23) -### Bugfix -- IsValid() -> !IsValid() +### Bugfix +- [d06fc13](https://github.com/taliesins/terraform-provider-hyperv/commit/d06fc1314f26f81989dfcdda1ff5782e627ea5e6) IsValid() -> !IsValid()