From c96e2736f8117d58d91ea38ce9fd9d3c3eb8ce97 Mon Sep 17 00:00:00 2001 From: Matan Kushner Date: Mon, 11 Apr 2022 08:30:11 -0500 Subject: [PATCH] ci: add release-please to automate release creation (#3847) --- .github/chglog/CHANGELOG.tpl.md | 49 --------------------------- .github/chglog/RELEASE.tpl.md | 29 ---------------- .github/chglog/changelog.yml | 37 -------------------- .github/chglog/release.yml | 36 -------------------- .github/workflows/deploy.yml | 49 ++++++++++++++++----------- .github/workflows/format-workflow.yml | 1 - 6 files changed, 29 insertions(+), 172 deletions(-) delete mode 100755 .github/chglog/CHANGELOG.tpl.md delete mode 100755 .github/chglog/RELEASE.tpl.md delete mode 100755 .github/chglog/changelog.yml delete mode 100755 .github/chglog/release.yml diff --git a/.github/chglog/CHANGELOG.tpl.md b/.github/chglog/CHANGELOG.tpl.md deleted file mode 100755 index 3346a56e..00000000 --- a/.github/chglog/CHANGELOG.tpl.md +++ /dev/null @@ -1,49 +0,0 @@ -{{ if .Versions -}} - -## [Unreleased] - -{{ if .Unreleased.CommitGroups -}} -{{ range .Unreleased.CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} - -{{ range .Versions }} - -## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }} -{{ range .CommitGroups -}} -### {{ .Title }} -{{ range .Commits -}} -- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{ end }} -{{ end -}} - -{{- if .RevertCommits -}} -### Reverts -{{ range .RevertCommits -}} -- {{ .Revert.Header }} -{{ end }} -{{ end -}} - -{{- if .NoteGroups -}} -{{ range .NoteGroups -}} -### {{ .Title }} -{{ range .Notes }} -{{ .Body }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} - -{{- if .Versions }} -[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD -{{ range .Versions -}} -{{ if .Tag.Previous -}} -[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }} -{{ end -}} -{{ end -}} -{{ end -}} diff --git a/.github/chglog/RELEASE.tpl.md b/.github/chglog/RELEASE.tpl.md deleted file mode 100755 index 465caeef..00000000 --- a/.github/chglog/RELEASE.tpl.md +++ /dev/null @@ -1,29 +0,0 @@ -{{ 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 -}} -### {{ .Title }} - -{{ range .Commits -}} -* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{ end }} -{{ end -}} - -{{- if .RevertCommits -}} -### Reverts - -{{ range .RevertCommits -}} -* {{ .Revert.Header }} -{{ end }} -{{ end -}} - -{{- if .NoteGroups -}} -{{ range .NoteGroups -}} -### {{ .Title }} - -{{ range .Notes }} -{{ .Body }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} diff --git a/.github/chglog/changelog.yml b/.github/chglog/changelog.yml deleted file mode 100755 index a1aa166b..00000000 --- a/.github/chglog/changelog.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -style: github -template: CHANGELOG.tpl.md -info: - title: CHANGELOG - repository_url: https://github.com/starship/starship -options: - commits: {} - commit_groups: - sort_by: Custom - title_order: - - feat - - fix - - docs - - style - - refactor - - perf - - test - - build - - ci - - chore - - revert - title_maps: - feat: Features - fix: Bug Fixes - perf: Performance Improvements - refactor: Code Refactoring - ci: Continuous Integration - header: - pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" - pattern_maps: - - Type - - Scope - - Subject - notes: - keywords: - - BREAKING CHANGE diff --git a/.github/chglog/release.yml b/.github/chglog/release.yml deleted file mode 100755 index a508ba8c..00000000 --- a/.github/chglog/release.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -style: github -template: RELEASE.tpl.md -info: - repository_url: https://github.com/starship/starship -options: - commits: {} - commit_groups: - sort_by: Custom - title_order: - - feat - - fix - - docs - - style - - refactor - - perf - - test - - build - - ci - - chore - - revert - title_maps: - feat: Features - fix: Bug Fixes - perf: Performance Improvements - refactor: Code Refactoring - ci: Continuous Integration - header: - pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" - pattern_maps: - - Type - - Scope - - Subject - notes: - keywords: - - BREAKING CHANGE diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a2f87ba4..b30adc46 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,8 +1,8 @@ name: Deploy on: push: - tags: - - "v*" + branches: + - master env: CARGO_INCREMENTAL: 0 CARGO_NET_RETRY: 10 @@ -10,9 +10,25 @@ env: RUSTUP_MAX_RETRIES: 10 jobs: + # Update release PR + release_please: + name: Release Please + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: rust + # Build sources for every OS github_build: name: Build release binaries + needs: release_please + if: ${{ needs.release_please.outputs.release_created }} strategy: fail-fast: false matrix: @@ -200,9 +216,9 @@ jobs: security delete-keychain $KEYCHAIN_PATH # Create GitHub release with Rust build targets and release notes - github_release: - name: Create GitHub Release - needs: [github_build, notarize_and_pkgbuild] + upload_artifacts: + name: Add Build Artifacts to Release + needs: [release_please, github_build, notarize_and_pkgbuild] runs-on: ubuntu-latest steps: - name: Setup | Checkout @@ -210,33 +226,24 @@ jobs: with: fetch-depth: 0 - - name: Setup | Go - uses: actions/setup-go@v2 - with: - go-version: "1.16" - - name: Setup | Artifacts uses: actions/download-artifact@v2 - name: Setup | Checksums run: for file in starship-*/starship-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done - - name: Setup | Release notes - run: | - go install github.com/git-chglog/git-chglog/cmd/git-chglog@v0.15.0 - git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md - - - name: Build | Publish + - name: Build | Add Artifacts to Release uses: softprops/action-gh-release@v1 with: files: starship-*/starship-* - body_path: RELEASE.md + tag_name: ${{ needs.release_please.outputs.release_created }} # Publish starship to Crates.io cargo_publish: name: Publish Cargo Package runs-on: ubuntu-latest - needs: github_release + needs: release_please + if: ${{ needs.release_please.outputs.release_created }} steps: - name: Setup | Checkout uses: actions/checkout@v3 @@ -254,7 +261,8 @@ jobs: update_brew_formula: name: Update Brew Formula runs-on: ubuntu-latest - needs: github_release + needs: release_please + if: ${{ needs.release_please.outputs.release_created }} steps: - uses: mislav/bump-homebrew-formula-action@v1.16 with: @@ -265,7 +273,8 @@ jobs: publish_docs: name: Publish docs to Netlify runs-on: ubuntu-latest - needs: github_release + needs: release_please + if: ${{ needs.release_please.outputs.release_created }} steps: - name: Setup | Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/format-workflow.yml b/.github/workflows/format-workflow.yml index 9e24f12f..5f41ae23 100644 --- a/.github/workflows/format-workflow.yml +++ b/.github/workflows/format-workflow.yml @@ -1,4 +1,3 @@ ---- name: Format + Docs Workflow on: push: